Kyle begins walking through the solution to exercise 4. First, he creates an add() function that will add two numbers. He then creates an add2() function that takes two functions instead of two numbers, calls each function, and sends those values to the add() function.
(samurai music)…- [Instructor] So, to start out with,…as the read me says, what we're going to have you do is write…two functions, I don't care, just call them foo…and bar for now, and each one of those functions should…return a different number, so have one of them return 10,…and one of them return 42, I don't care, pick your…favorite numbers, but literally just have it…return a number, okay?…Your functions probably look something roughly like that.…Okay?…Now, there's something interesting…in functional programming, there's interesting about the…nature of having a value wrapped in a function.…
Kind of like I said earlier, that there's an instinct…to say well, if given the option,…I try to stuff values into a list…because I know lists can, I can do certain sorts of…operations on lists that are quite handy.…In the same way, you also sometimes will say,…if I can wrap a value in a function, and I know if calling…that function will give me the value,…that starts to produce patterns of more compose-ability…in our programs.…
This course was created by Frontend Masters. It was originally released on 03/08/2016. We're pleased to host this training in our library.
- Pure functions
- Manual composition
- Composition utility
- List operations
Skill Level Intermediate
1. Pure Functions
2. Composition and Immutability
3. Closure and Recursion
4. List Operations
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
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.