You’ve finished Functions You Can Pass Around, and Tomás’s movie night has its picker. Most of what you built in the course rests on one idea: a function is a value, like a number or a string, so you can store it, pass it, and hand it to another function to call later.
In This Course, You Learned How To
- Store functions in variables, pass them to other functions, and give parameters defaults
- Keep a watchlist up to date and check what’s in it with array methods, and build records with shorthand
- Transform, filter, search, and sort a list of records by handing functions to array methods
- Build Tomás’s movie-night picker, and explain what each callback receives and returns
Things to Remember
filter(fitsTonight)hands the function over, andfitsTonight(film)calls it now.- When the argument is
undefined, a default parameter fills in. - Ask every array method two questions: does it change the array, and what does it return?
- The callback’s return value decides what
map(),filter(), andfind()give back. - Numbers need a comparator in
sort()andtoSorted()alike. Thesort()method changes the array, andtoSorted()returns a sorted copy.