1.7 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			1.7 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", "Do not change the value of the global <code>outerWear</code>");'
  - text: <code>myOutfit</code>应该返回<code>"sweater"</code>
    testString: 'assert(myOutfit() === "sweater", "<code>myOutfit</code> should return <code>"sweater"</code>");'
  - text: 不要更改return语句
    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