Last active
January 24, 2017 14:21
-
-
Save marcoala/e57f78de365f15826dcec786da87ee7d to your computer and use it in GitHub Desktop.
Ask the candidate what s/he can say about this code, and what the output is.
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 createFunctions() { | |
var i; | |
var functions = []; | |
for (i = 0; i < 5; i++){ | |
functions[i] = function(){ | |
console.log(i); | |
}; | |
} | |
return functions; | |
} | |
var funcs = createFunctions(); | |
funcs[2](); | |
funcs[4](); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment