In this exercise, modify the for loop in the ex1.js file and add functions to the fns array. These functions use the let and const keywords to ensure the correct closures are created, and the assertion at the bottom of the file remains true.
(driving music)…- Let's open up Exercise One.…You notice that I've created some functions here,…and I've created some for loops and stuff.…And here's our test case at the bottom,…it needs to assert true.…Which is the case that the x value of two multiplied by two,…so we're saying that four needs to be the same thing…that's returned if I call the function in this fns array,…at position four.…So in other words, I'm gonna loop over…from zero up to five, not including,…and I'm gonna add functions to an fns array.…
Each one of those functions needs to close…over some variable, such that when the function is called,…it returns that value,…okay?…So looking at your iffy here,…looking at your var statements,…figure out which ones of these should be made…into lets and conts, and refactor this code,…and set yourself up correctly with your closure.…Should only take a few lines of code,…so we'll just take a three-minute break,…and then we'll talk about the solution.…
This course was created by Frontend Masters. It was originally released on 01/10/2017. We're pleased to host this training in our library.
- The arrow function
- Arrow function variations
- Closures and explicit blocks
- Default values
- Using the gather and spread operators
- Dumping variables
- Concise properties and methods
- Symbols, iterators, and generators
- Optimizing codes for the reader
Skill Level Intermediate
1. Arrow Functions
2. Block Scope
3. Default Values and the Gather/Spread Operators
5. Template Strings
6. Symbols, Iterators, and Generators
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.