1
2
3
4
5
6
7
8
9
10
To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to CodePen.
0,1,2,3,4,5,6,7,8,9
0
0
0
0
An outer function takes itself out of the picture when it ______ its inner function. | returns | returns | |
Given the following code, what string won't display? | function outerFunc() { let greeting = "Hello"; function innerFunc() { greeting = "G'day"; console.log(greeting); } return innerFunc; } const aVar = outerFunc(); aVar(); |
"Hello" | •?Hello•? |
Given the following code, what is the final value of aVar? | function outerFunc() { let greeting = "Hello"; function innerFunc() { greeting = "G'day"; console.log(greeting); } return innerFunc; } const aVar = outerFunc(); aVar(); |
innerFunc" | innerFunc |
Fill in the blank to complete the closure. | function outerFunc() { let greeting = "Hello"; function innerFunc() { greeting = "G'day"; console.log(greeting); } _______________ } const aVar = outerFunc(); aVar(); |
return innerFunc | returninnerFunc |
One statement in the outer function is longer than it needs to be. Rewrite it. | function outerFunc() { let greeting = "Hello"; function innerFunc() { greeting = "G'day"; console.log(greeting); } return innerFunc; } const aVar = outerFunc(); aVar(); |
let greeting; | letgreeting; |
Given the following code, what value will the console display? | function count() { let num = 0; function incrementNum() { return num += 1; } return incrementNum; } const aVar = count(); console.log(aVar()); |
1 | 1 |
Given the following code, what value will the console display? | function count() { let num = 0; function incrementNum() { return num += 1; } return incrementNum; } const aVar = count(); console.log(aVar() + aVar()); |
3 | 3 |
Given the following code, what value will be displayed? | function outer() { let num = 0; function inner() { if (num < 1) { return 1; } } return inner; } const getNum = outer(); console.log(getNum()); |
1 | 1 |
|
|||
|