---
title: Compare Scopes of the var and let Keywords
---

 Remember to use **`Read-Search-Ask`** if you get stuck. Try to pair program  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
*   Find `var` and replace with `let`.
> _try to solve the problem now_
*   Add `let` to the variable `i` inside of your if statement.
> _try to solve the problem now_
## Spoiler Alert!

**Solution ahead!**
##  Basic Code Solution:
```javascript
    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;
    }
```
 Run Code
# Code Explanation:
By using `let` you can declare variables in relation to their scope.
#### Relevant Links
*   let
##  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.
*   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_)
> See  **`Wiki Challenge Solution Template`** for reference.