Last active
October 24, 2016 14:36
-
-
Save peterchaula/de39d604caf70ff4dcd306452beac776 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
/** | |
Fix this code | |
var multiplyByIndex = []; | |
for (var i = 0; i < 100; i ++) { | |
multiplyByIndex[i] = function(inputNum) { | |
return inputNum * i; | |
}; | |
} | |
multiplyByIndex[5](2) | |
output: 200 | |
*/ | |
var multiplyByIndex = []; | |
for (var i = 0; i < 100; i ++) { | |
multiplyByIndex[i] = (function(i) { | |
return function(inputNum){ | |
return inputNum * i; | |
}; | |
})(i); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment