Which value will be displayed?

You have a webpage that includes the following markup and code:

You need to troubleshoot the code by clicking the Submit button.
Which value will be displayed?

You have a webpage that includes the following markup and code:

You need to troubleshoot the code by clicking the Submit button.
Which value will be displayed?

A.
10

B.
20

C.
Undefined

D.
Runtime error



Leave a Reply 6

Your email address will not be published. Required fields are marked *


Alex

Alex

I have an offtop question: how do you call the “fun” function?

noobs

noobs

you cant, it is a private variable of start function

Robert Barr

Robert Barr

You should be able to call if from within start()… right?

Fack

Fack

Undefined is true!

Dmitry C

Dmitry C

function start() {
var counter = 10
var fun = function () {
counter = 20;
}
return counter;
}

console.log(start());

Jacob

Jacob

I tested it, it displays “10”. var fun is never called so the counter is not ever updated to 20, and its definitely not undefined or a runtime error.