1.8 KiB
1.8 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
56533eb9ac21ba0edf2244c0 | Global vs. Local Scope in Functions | 1 | Escopo global vs. local em funções |
Description
local
tem precedência sobre a variável global
. Neste exemplo: var someVar = "Chapéu";A função
function myFun () {
var someVar = "Head";
return someVar;
}
myFun
retornará "Head"
porque a versão local
da variável está presente. Instructions
myOutfit
para substituir o valor de outerWear
por "sweater"
. Tests
tests:
- text: Não altere o valor do <code>outerWear</code> global
testString: 'assert(outerWear === "T-Shirt", "Do not change the value of the global <code>outerWear</code>");'
- text: <code>myOutfit</code> deve retornar <code>"sweater"</code>
testString: 'assert(myOutfit() === "sweater", "<code>myOutfit</code> should return <code>"sweater"</code>");'
- text: Não altere a declaração de retorno
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