Skip to content

Instantly share code, notes, and snippets.

@joepie91
Forked from anonymous/gist:3033819
Created July 2, 2012 15:56
Show Gist options
  • Save joepie91/3033934 to your computer and use it in GitHub Desktop.
Save joepie91/3033934 to your computer and use it in GitHub Desktop.
//this function adds 3 to the number passed in
function addThree(x) {
return x + 3;
}
//this function takes a function and returns
//a function that runs the function it was passed,
//and then runs that function _again_ on the return
//value of the first call to the function.
//make sense? look at it until it does.
function composed() {
return function(number) { // this is a function *definition*, not really a function call!
return addThree(addThree(number))
}
}
composed()(4); // this actually runs whatever_was_returned_from_composed(4);
//what does that return?
var answer = ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment