--- id: 56533eb9ac21ba0edf2244c0 title: Global vs. Local Scope in Functions challengeType: 1 videoUrl: '' localeTitle: Escopo global vs. local em funções --- ## Description
É possível ter variáveis locais e globais com o mesmo nome. Quando você faz isso, a variável local tem precedência sobre a variável global . Neste exemplo:
var someVar = "Chapéu";
function myFun () {
var someVar = "Head";
return someVar;
}
A função myFun retornará "Head" porque a versão local da variável está presente.
## Instructions
Adicione uma variável local à função myOutfit para substituir o valor de outerWear por "sweater" .
## Tests
```yml tests: - text: Não altere o valor do outerWear global testString: 'assert(outerWear === "T-Shirt", "Do not change the value of the global outerWear");' - text: myOutfit deve retornar "sweater" testString: 'assert(myOutfit() === "sweater", "myOutfit should return "sweater"");' - text: Não altere a declaração de retorno testString: 'assert(/return outerWear/.test(code), "Do not change the return statement");' ```
## 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 // solution required ```