ES6 - Compare Scopes of the var and let Keywords

Tell us what’s happening:
Describe your issue in detail here.
Do I put return = “function scope”; ?
Your code so far

function checkScope() {
   i = 'function scope';
  if (true) {
  if  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 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36

Challenge: ES6 - Compare Scopes of the var and let Keywords

Link to the challenge:

Two changes need to be made.

  1. You need to change the var in the initial code to a let

  2. You need to declare the i variable inside the if statement, again using let

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.