Created
June 28, 2020 10:59
-
-
Save hw0k/021ee7a8a77ed7ae54e5b74ef8df2da6 to your computer and use it in GitHub Desktop.
FND 9
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
function pipe(...functions) { | |
return input => functions.reduce((value, func) => func(value), input); | |
} | |
function multiplyTwice(x) { | |
return x * 2; | |
} | |
function addFive(x) { | |
return x + 5; | |
} | |
const number = 3; | |
// pipe()가 없을 때 | |
addFive(multiplyTwice(number)); | |
// pipe()를 사용했을 때 | |
const multiplyAndAdd = pipe(multiplyTwice, addFive); | |
multiplyAndAdd(number); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment