2.0 KiB
2.0 KiB
id, title, challengeType, videoUrl, localeTitle
| id | title | challengeType | videoUrl | localeTitle |
|---|---|---|---|---|
| 56533eb9ac21ba0edf2244c0 | Global vs. Local Scope in Functions | 1 | نطاق عالمي مقابل نطاق محلي في الوظائف |
Description
local الأسبقية على المتغير global . في هذا المثال: var someVar = "Hat" ،ستقوم الدالة
وظيفة myFun () {
var someVar = "الرأس" ؛
عودة بعض
}
myFun بإرجاع "Head" لأن الإصدار local للمتغير موجود. Instructions
myOutfit لتجاوز قيمة outerWear مع "sweater" . 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: لا تقم بتغيير بيان الإرجاع
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