Created
March 27, 2021 17:18
-
-
Save coderdiaz/7c3c83fddb28753eb1256ae69b0e2d3e 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 launchAll(missiles, launchMissile) { | |
for(var i = 0; i < 5; i++) { | |
setTimeout(function() { | |
launchMissile(i); | |
}, i * 1000); | |
} | |
} | |
// [1, 2, 3, 4, 5] | |
launchAll([1, 2, 3, 4, 5], (missile) => { | |
console.log(`Launch missile #${missile}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment