Can we figure out

Tell us what’s happening:

I am trying to find the answer to this part? Some helpies would be coolio!

Your code so far


function checkScope() {
'use strict';
var i = 'function scope';
if (true) {
  i = 'block scope';
  console.log('Block scope i is: ', i);
}
console.log('Function scope i is: ', i);
return i;
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36 Edg/84.0.522.50.

Challenge: Compare Scopes of the var and let Keywords

Link to the challenge:

So, right now, there is one variable named i. They are asking you to make two. The first one, declaring var i='function scope', should be changed - one of the tests ask if var is being used, and it shouldn’t be.

The second one is a little tricky to understand. See, let declares a variable that only exists inside it’s block (typically, that means inside an {...}, like a for loop or an if statement). In this case, you have an if(true){...} and inside those curly braces, we can use let i=/* something...?*/ to define a locally scoped variable (so i inside the if isn’t the same as i outside of it).

Can you see a place inside that if(true){...} where i is being assigned a value, where you can add something to make it a completely different variable with the same name?