Tell us what’s happening:
I do not understand why my browser console does not yield the same results as FreeCodeCamp.
Your code so far
The following code passed the test in the ES6: Compare Scopes of the var and let Keywords exercise:
function checkScope() {
"use strict";
let i = "function scope";
if (true) {
let i = "block scope";
console.log("Block scope i is: ", i);
}
console.log("Function scope i is: ", i);
return i;
};
But when I paste that same code into my browser (Inpsect > console) I get this result:
undefined
Why the different results? How can I get the browser console to instead say
Block scope i is: block scope
Function scope i is: function scope
I am very confused. I have never come across a discrepancy like this before. I am using the latest version of Google Chrome.
Thanks in advance for your help.
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/compare-scopes-of-the-var-and-let-keywords