Skip to content

Instantly share code, notes, and snippets.

@stevewillard
Created August 4, 2008 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stevewillard/3892 to your computer and use it in GitHub Desktop.
Save stevewillard/3892 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));
alert(plus_three(5));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment