freeCodeCamp/curriculum/challenges/arabic/02-javascript-algorithms-an.../es6/compare-scopes-of-the-var-a...

1.1 KiB

id title challengeType videoUrl localeTitle
587d7b87367417b2b2512b40 Compare Scopes of the var and let Keywords 1

Description

undefined

Instructions

undefined

Tests

tests:
  - text: ''
    testString: 'getUserInput => assert(!getUserInput("index").match(/var/g),"<code>var</code> does not exist in code.");'
  - text: ''
    testString: 'getUserInput => assert(getUserInput("index").match(/(i\s*=\s*).*\s*.*\s*.*\1("|")block\s*scope\2/g), "The variable <code>i</code> declared in the if statement should equal "block scope".");'
  - text: ''
    testString: 'assert(checkScope() === "function scope", "<code>checkScope()</code> should return "function scope"");'

Challenge Seed

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;
}

Solution

// solution required