--- id: 56533eb9ac21ba0edf2244c0 title: Global vs. Local Scope in Functions challengeType: 1 videoUrl: '' localeTitle: Ámbito global vs. local en funciones --- ## Description
Es posible tener variables locales y globales con el mismo nombre. Cuando haces esto, la variable local tiene prioridad sobre la variable global . En este ejemplo:
var someVar = "Hat";
función myFun () {
var someVar = "Head";
devuelve someVar;
}
La función myFun devolverá "Head" porque la versión local de la variable está presente.
## Instructions
Agregue una variable local a la función myOutfit para anular el valor de outerWear con "sweater" .
## Tests
```yml tests: - text: No cambie el valor de la outerWear global testString: 'assert(outerWear === "T-Shirt", "Do not change the value of the global outerWear");' - text: myOutfit debe devolver "sweater" testString: 'assert(myOutfit() === "sweater", "myOutfit should return "sweater"");' - text: No cambie la declaración de devolución 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 ```