What will be the result of the following code?
 function myFunction() {
    var a = 1;
    if ( a == 1 ) {
        var b = 2;
    }
    return b;
}
myFunction();
 
Explanation
In JavaScript 'var' declares the variable inside the scope of the function.

@sokurenko40 thanks as well! your comment was lost

2019 Jul 14, 4:39:09 PM

Thanks a lot, @monsieurtoul08 . Fixed :)

2019 Jul 14, 4:38:29 PM

As the function is not called, there is no result...

2019 Jul 9, 10:08:22 PM

There isn't the function call.

2018 Sep 11, 6:28:44 AM

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes