local
variable takes precedence over the global
variable.
In this example:
var someVar = "Hat";The function
function myFun() {
var someVar = "Head";
return someVar;
}
myFun
will return "Head"
because the local
version of the variable is present.
myOutfit
function to override the value of outerWear
with "sweater"
.
outerWear
testString: assert(outerWear === "T-Shirt", 'Do not change the value of the global outerWear
');
- text: myOutfit
should return "sweater"
testString: assert(myOutfit() === "sweater", 'myOutfit
should return "sweater"
');
- text: Do not change the return statement
testString: assert(/return outerWear/.test(code), 'Do not change the return statement');
```