--- id: 56533eb9ac21ba0edf2244c0 title: Global vs. Local Scope in Functions challengeType: 1 videoUrl: 'https://scrimba.com/c/c2QwKH2' forumTopicId: 18194 --- ## Description
It is possible to have both local and global variables with the same name. When you do this, the local variable takes precedence over the global variable. In this example: ```js var someVar = "Hat"; function myFun() { var someVar = "Head"; return someVar; } ``` The function myFun will return "Head" because the local version of the variable is present.
## Instructions
Add a local variable to myOutfit function to override the value of outerWear with "sweater".
## Tests
```yml tests: - text: You should not change the value of the global outerWear. testString: assert(outerWear === "T-Shirt"); - text: myOutfit should return "sweater". testString: assert(myOutfit() === "sweater"); - text: You should not change the return statement. testString: assert(/return outerWear/.test(code)); ```
## Challenge Seed
```js // Setup var outerWear = "T-Shirt"; function myOutfit() { // Only change code below this line // Only change code above this line return outerWear; } myOutfit(); ```
## Solution
```js var outerWear = "T-Shirt"; function myOutfit() { var outerWear = "sweater"; return outerWear; } ```