Skip to content

Instantly share code, notes, and snippets.

@coderdiaz
Created March 27, 2021 17:18
Show Gist options
  • Save coderdiaz/7c3c83fddb28753eb1256ae69b0e2d3e to your computer and use it in GitHub Desktop.
Save coderdiaz/7c3c83fddb28753eb1256ae69b0e2d3e to your computer and use it in GitHub Desktop.
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