Tell us what’s happening:
i am getting answer 5, twice. what’s wrong. even after deleting console.log outside the function.
Your code so far
function myLocalScope() {
'use strict';
// Only change code below this line
var myVar=5;
console.log(myVar);
}
myLocalScope();
// Run and check the console
// myVar is not defined outside of myLocalScope
// Now remove the console log line to pass the test
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36.
Hi, the test does pass with two 5s because the console.log is showing the value of myVar inside the function as well as logging the value of myVar when the function is called
Thank you, for pointing this out. It is very interesting behaviour, and we have been discussing the accuracy of the built-in freeCodeCamp console, over on this GitHub issue.
i have another question : if i declared without var ie. myvar=5(global scope without var key word); in the same question under function, and if i log console.log(myVar), it should log 5, is it right?