* fix: Chinese test suite Add localeTiltes, descriptions, and adjust test text and testStrings to get the automated test suite working. * fix: ran script, updated testStrings and solutions
1.5 KiB
1.5 KiB
id, title, challengeType, videoUrl, localeTitle
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
56533eb9ac21ba0edf2244c0 | Global vs. Local Scope in Functions | 1 | 功能中的全局与局部范围 |
Description
local
变量优先于global
变量。在这个例子中: var someVar =“帽子”;函数
function myFun(){
var someVar =“Head”;
返回someVar;
}
myFun
将返回"Head"
因为存在变量的local
版本。 Instructions
myOutfit
函数,以使用"sweater"
覆盖outerWear
的值。 Tests
tests:
- text: 不要更改全局<code>outerWear</code>的值
testString: assert(outerWear === "T-Shirt");
- text: <code>myOutfit</code>应该返回<code>"sweater"</code>
testString: assert(myOutfit() === "sweater");
- text: 不要更改return语句
testString: assert(/return outerWear/.test(code));
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