Last active
May 23, 2019 17:36
-
-
Save martin-mok/3db267016be01b9daf8900b523d5997d 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
/* | |
It's a scoping bug, it can be corrected by using let | |
*/ | |
function createArrayOfFunctions(y) { | |
/* | |
A function that create an array of function, each have one input, and return the input value by adding the index | |
*/ | |
let arr = []; | |
for (let i = 0; i < y; i++) { | |
arr[i] = function(x) { | |
return x + i; | |
}; | |
} | |
return arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment