Check out a free preview of the full Functional-Lite JavaScript course:
The "Exercise 2" Lesson is part of the full, Functional-Lite JavaScript course featured in this preview video. Here's what you'd learn in this lesson:

In this exercise, you will use closure to define a foo() function that returns a function. This returned function remembers only the first two arguments that were passed to foo() and always adds them together.

Get Unlimited Access Now

Transcript from the "Exercise 2" Lesson

[00:00:00]
>> [MUSIC]

[00:00:03]
>> Kyle Simpson: Pull exercise two up with me. Again, pull up the read me and the EX2.js.
>> Kyle Simpson: I'll go ahead and close exercise one, since we're not using that anymore. Let's look at the read me for exercise two. It says define foo so that it produces a function, we've already seen that, and that function needs to remember only the first two arguments that were passed to foo.

[00:00:26] And then the function that we've returned back, it needs to always add those two together.
>> Kyle Simpson: Parse through that read me.
>> Kyle Simpson: Make sure you fully understand what it's asking for, here's the set up.
>> Kyle Simpson: I should be able to make a function called x that's already remembering the 3 and the 4, and every time I call x I'm gonna get 7 out.

[00:00:53]
>> Kyle Simpson: Not very many lines of code, but let's make sure you have your brains wrapped around how we can use closure, okay?