We'll learn how to take advantage of Ramda's automatic function currying and data-last argument order to combine a series of pure functions into a left-to-right composition, or pipeline, with Ramda's pipe function.
the code in CODE TAB does not reflect what the presenter in the video was teaching. Is there a reason why/
Charles,
First of all, thanks for watching!
The code in the code tab does have a couple of slight differences, but the core result of the lesson is represented. The key differences are that in the video, I am running the code with Node and use a require
to import the library. In the embedded example, Ramda is being pulled into the browser through a script tag.
The second difference is that there is an additional line at the bottom of the code sample, simply for the purpose of showing the results in the result pane rather than forcing you to open your console.
The third difference is that the commented out version of the code has been removed from the embedded example for clarity.
I hope this helps and thanks again for watching!
Slightly concise version using reduce.
const findTopTeam = R.reduce((a,b) => a.score > b.score ? a : b, {score: 0})
const getName = R.prop('name')
const getTopName = R.pipe(findTopTeam, getName)
Sen,
Nice optimization!