Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const double = x => x * 2
- const getLength = string => string.length
- const map = (collection, fn) => collection.map(fn)
- const messages = ['Hello', 'Bye']
- const mapToLengths = collection => map(collection, getLength)
- const mapToDoubles = collection => map(collection, double)
- const pipe = (...fns) => input => fns.reduce((mem, fn) => fn(mem), input)
- const doubleLengths = pipe(mapToLengths, mapToDoubles)(messages)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement