Created
November 7, 2020 16:09
-
-
Save bunnyhawk/64b466534f638a3602bdabc308949005 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const pipe = (...fns) => x => fns.reduce((y, fn) => fn(y), x); | |
const addOne = num => num + 1; | |
const subtractTwo = num => num - 2; | |
const square = num => num * num; | |
const quickMaths = pipe(addOne, subtractTwo, square); | |
quickMaths(20); | |
// Returns: 361 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment