3.1 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			3.1 KiB
		
	
	
	
	
	
	
	
title
| title | 
|---|
| Compare Scopes of the var and let Keywords | 
 Remember to use
 Remember to use Read-Search-Ask if you get stuck. Try to pair program  and write your own code
 and write your own code 
Problem Explanation:
We need to change var to let in our function scope and add let to our block scope.
 Hint: 1
 Hint: 1
- Find varand replace withlet.
try to solve the problem now
- Add letto the variableiinside of your if statement.
try to solve the problem now
Spoiler Alert!
Solution ahead!
 Basic Code Solution:
 Basic Code Solution:
    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;
    }
Code Explanation:
By using let you can declare variables in relation to their scope.
Relevant Links
 NOTES FOR CONTRIBUTIONS:
 NOTES FOR CONTRIBUTIONS:
 DO NOT add solutions that are similar to any existing solutions. If you think it is similar but better, then try to merge (or replace) the existing similar solution. DO NOT add solutions that are similar to any existing solutions. If you think it is similar but better, then try to merge (or replace) the existing similar solution.
- Add an explanation of your solution.
- Categorize the solution in one of the following categories — Basic, Intermediate and Advanced.  
- Please add your username only if you have added any relevant main contents. ( DO NOT remove any existing usernames) DO NOT remove any existing usernames)
See

Wiki Challenge Solution Templatefor reference.


