Adrian Bracamonte#135
Conversation
dtacheny
left a comment
There was a problem hiding this comment.
Great work. It seems like you have a good understanding of these concepts!
| const increment = () => { | ||
| return ++count | ||
| } | ||
| return increment() |
There was a problem hiding this comment.
For this we want to return the function increment itself, not the result of invoking increment(). We want newCounter to be equivalent to increment.
So here's what we want to happen:
- Invoke
counter()and assign the result tonewCounter
Right now, newCounter has a value of 1, because that's the result of invoking increment on line 20. Instead, we want newCounter to have value that is the function increment. So we'd need to take the parentheses off of increment() on line 20.
- We want to be able to invoke
newCounterto increment thecountvariable inside of thecounterfunction.
Since we now have newCounter assigned to the function increment, we can invoke it just like any other function. So on lines 26 and 27, we want to add parentheses after newCounter to invoke the increment function and increment the count variable.
No description provided.