This course has been updated! We now recommend you take the Hardcore Functional Programming in JavaScript, v2 course.

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

This exercise focuses on combining methods through composition to create a better separation of concerns. Joe spends a few minutes describing the challenges and getting the audience started on the exercise. - Problem:

Get Unlimited Access Now

Transcript from the "Composition Exercise" Lesson

>> [MUSIC]

>> Joe Nelson: So here's our jsbin jevag. I'm gonna do some composing.
>> Off Camera 1: [INAUDIBLE]
>> Joe Nelson: Yeah, good idea. This time I'm gonna put it in a different browser so it doesn't know me as the creator, so when I type things, it doesn't change the original.
>> Joe Nelson: Okay.
>> Joe Nelson: Okay, so like the other ones, we have this underscore.

[00:00:42] It's actually Ramda, it's coming from Ramda. We created a little helper, which was get, like we were talking about before to pull something off an object and it's curried.
>> Off Camera 1: I think Ramda has that built in actually.
>> Joe Nelson: So- [LAUGH]
>> Off Camera 1: So would you look at a Ramda [LAUGH]

>> Joe Nelson: So it starts with an example of how you could use compose. In fact if I run it, we will be able to see some output, I hope. Refresh.
>> Joe Nelson: There it is, cool. So we could make this function that given an array of words because see we have words in here, we split.

[00:01:32] You actually give it a string, looking at this, double checking. You give it a string, it takes out the words and then it gives you the links of the words. So maybe you want to make a histogram of like how complicated words are in a grade level analyzer in a word processor or something.

[00:01:51] So here's how you do it with compose. I don't have to make it. I just throw stuff together. So that's an example then it's our turn to take like something an API might have given us back about articles, and authors, and stuff.
>> Joe Nelson: And get a list of the names inside of the articles.

>> Joe Nelson: So once again, we have identity written here, that just means change this out.
>> Joe Nelson: Get compose and map.
>> Off Camera 1: [INAUDIBLE] Now we don't have to do anything. I was like wait a second, we should do this.
>> Joe Nelson: I was telling [INAUDIBLE]
>> Off Camera 1: [LAUGH]
>> Off Camera 1: I feel like if we are going to use the jsbin and the refresh Ramda thing, we should figure that out.

[00:03:20] It's weird, cuz it's supposed to be synchronous in the script tag, it's just a HTML script tag, we should be doing that first.
>> Joe Nelson: Yeah we could add an asynchronous loader thing, it gets it already.
>> Off Camera 1: Yeah, said timeout or set interval.
>> Joe Nelson: Yeah, I thought scripts at the top blocked the page [CROSSTALK]

>> Off Camera 1: Why don't we block the page? Jsbin doing some weird stuff.. Casper Milquetoast is my favorite author.
>> Joe Nelson: Lessons for all of us.