Created
August 4, 2008 13:48
-
-
Save stevewillard/3892 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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