January 2020
Intermediate to advanced
470 pages
11h 13m
English
8.1. Headline capitalization: We can make use of several functional equivalents of different methods, such as split(), map(), and join(). Using demethodize() from Chapter 6, Producing Functions – Higher-Order Functions, and flipTwo() from Chapter 7, Transforming Functions – Currying and Partial Application, would have also been possible:
const split = str => arr => arr.split(str);const map = fn => arr => arr.map(fn);const firstToUpper = word => word[0].toUpperCase() + word.substr(1).toLowerCase();const join = str => arr => arr.join(str);const headline = pipeline(split(" "), map(firstToUpper), join(" "));
The pipeline works as expected: we split the string into words, we map each ...
Read now
Unlock full access