Last active
September 8, 2017 10:16
-
-
Save lspdv/be7e57bd8deea775dd2cf0b13c880f3a to your computer and use it in GitHub Desktop.
How would you change the second line in the following example so that it prints numbers 0, 1, 2, 3 in this order
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
//How would you change the second line in the following example so that it prints numbers 0, 1, 2, 3 in this order? | |
//Please answer fill only to the registration form for MSD Code Academy :-) | |
for (var i = 0; i < 4; i++) { | |
setTimeout(() => console.log(i), 0) | |
} | |
//A: By changing line 2) ... (function(number) { setTimeout(() => console.log(number), 0)})(i) | |
//B: By changing line 1) ... for (let i = 0; i < 4; i++) { | |
//C: By changing line 2) ... var temp = i; setTimeout(() => console.log(temp), 0) | |
//D: By changing line 2) ... setTimeout((i) => console.log(i), 0) | |
//E: Have no idea |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment