Last active
April 27, 2018 17:31
-
-
Save ashleycoker/81fc23a107d98d3eb4232e93a2f6ca59 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 createOperations(){ | |
var operations = []; | |
for (var i = 0; i < 5; i++) { | |
operations.push(function(input){ | |
return input * i; | |
}) | |
} | |
return operations; | |
} | |
var ops = createOperations(); | |
for (var i = 0; i < 5; i++) { | |
alert(ops[i](i)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment