Tell us what’s happening:
What is the if checking?
my guess is it doesn’t check anything. the code will run no matter what. On the flip side, if I change it to if(false), the code will NOT run.
I checked both MDN and W3School. They don’t have example where the condition is just a true or false. There is always a varible, a string or a number.
Many thanks
Your code so far
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;
}
function test (a){a==1||a==2?console.log("right"):console.log("wrong")};
test(1)
test(2)
test(3)
test(4)
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 Safari/605.1.15
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/compare-scopes-of-the-var-and-let-keywords