Skip to content

Instantly share code, notes, and snippets.

@stpettersens
Last active July 4, 2016 07:10
Show Gist options
  • Save stpettersens/107f1fa1f8d95707bd306a4ee9c2f195 to your computer and use it in GitHub Desktop.
Save stpettersens/107f1fa1f8d95707bd306a4ee9c2f195 to your computer and use it in GitHub Desktop.
Coolifier example in JS (function which returns a function) [@vakila]
/*
Adapted from Anjana Vakil's (@vakila) Learning Functional Programming with JavaScript presentation @ JSUnconf 2016
https://youtu.be/e-5obm1G_FY?t=9m24s
*/
'use strict'
function makeAdjectifier (adjective) {
return function (string) {
return adjective + ' ' + string
}
}
const coolifier = makeAdjectifier('cool')
coolifier('conference') // ==> "cool conference"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment