1.8 KiB
1.8 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
56533eb9ac21ba0edf2244c0 | Global vs. Local Scope in Functions | 1 | Ámbito global vs. local en funciones |
Description
local
tiene prioridad sobre la variable global
. En este ejemplo: var someVar = "Hat";La función
función myFun () {
var someVar = "Head";
devuelve someVar;
}
myFun
devolverá "Head"
porque la versión local
de la variable está presente. Instructions
myOutfit
para anular el valor de outerWear
con "sweater"
. Tests
tests:
- text: No cambie el valor de la <code>outerWear</code> global
testString: 'assert(outerWear === "T-Shirt", "Do not change the value of the global <code>outerWear</code>");'
- text: <code>myOutfit</code> debe devolver <code>"sweater"</code>
testString: 'assert(myOutfit() === "sweater", "<code>myOutfit</code> should return <code>"sweater"</code>");'
- text: No cambie la declaración de devolución
testString: 'assert(/return outerWear/.test(code), "Do not change the return statement");'
Challenge Seed
// Setup
var outerWear = "T-Shirt";
function myOutfit() {
// Only change code below this line
// Only change code above this line
return outerWear;
}
myOutfit();
Solution
// solution required