In this activity you will work on this user story:
- As a developer, I want to demonstrate my knowledge of closures by creating a
makeCountDown
function that accesses the surrounding function state.
-
It's done when I have created a function
makeCountDown
that returns a nested function. -
It's done when I have set the return value of
countDown
to a variable calledcountingDown
. -
It's done when invoking the
countingDown
for the first time will start a countdown fromstartingNum
. -
It's done when every subsequent invocation of
countDown
returns thestartingNum
subtracted from thedecreasedBy
variable.
- Refer to the MDN Documentation on Closures
-
How can we use the comments inside
index.js
to guide us in what our inner function should return? -
What kind of function is one that creates other functions?
- Using Google, what are some complications you might run into when using closures within for loops?