Skip to content

Instantly share code, notes, and snippets.

@ronal2do
Last active May 28, 2018 19:20
Show Gist options
  • Save ronal2do/1999e04c5fdd814d0f2ac58f13269c11 to your computer and use it in GitHub Desktop.
Save ronal2do/1999e04c5fdd814d0f2ac58f13269c11 to your computer and use it in GitHub Desktop.
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