Last active
May 28, 2018 19:20
-
-
Save ronal2do/1999e04c5fdd814d0f2ac58f13269c11 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 f = x => x + 1 | |
const g = x => x * 2 | |
const x = 3 | |
const result = f(g(x)) // 7 | |
const scream = str => str.toUpperCase() | |
const exclaim = str => `${str}!` | |
const repeat = str => `${str} ${str}` | |
const string = 'Awesome' | |
const result = repeat(exclaim(scream(string))) // AWESOME! AWESOME! | |
const compose = ( ...fns ) => | |
fns.reduceRight( ( acc, fn ) => fn(acc), x ) | |
const enhance = compose( repeat, exclaim, scream ) | |
enhance( string ) // AWESOME! AWESOME! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment