Skip to content

Instantly share code, notes, and snippets.

@JosephPecoraro
Forked from stevewillard/gist:3892
Created August 4, 2008 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JosephPecoraro/3894 to your computer and use it in GitHub Desktop.
Save JosephPecoraro/3894 to your computer and use it in GitHub Desktop.
function make_adder( left_operand ) {
return function ( right_operand ) {
return left_operand + right_operand;
};
}
// so, you can say:
var plus_two = make_adder(2);
var plus_three = make_adder(3);
alert(plus_two(5)); //=> 7
alert(plus_three(5)); //=> 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment