Skip to content

Adrian Bracamonte#135

Open
adrianbraca wants to merge 3 commits intobloominstituteoftechnology:masterfrom
adrianbraca:master
Open

Adrian Bracamonte#135
adrianbraca wants to merge 3 commits intobloominstituteoftechnology:masterfrom
adrianbraca:master

Conversation

@adrianbraca
Copy link

No description provided.

Copy link

@dtacheny dtacheny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work. It seems like you have a good understanding of these concepts!

const increment = () => {
return ++count
}
return increment()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Invoke counter() and assign the result to newCounter

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.

  1. We want to be able to invoke newCounter to increment the count variable inside of the counter function.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants