Last active
June 9, 2018 14:04
-
-
Save GitSquared/9c5c9fe5985a14c35e2773fc9a96ade8 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
console.log("START"); | |
let i = 0; | |
let left = ["left_one", "left_two", "left_three", "left_four"]; | |
let right = ["right_one", "right_two"]; | |
let x = setInterval(() => { | |
if (!left[i] && !right[i]) { | |
console.log("DONE!"); | |
clearInterval(x); | |
} else { | |
console.log(`RUN ${i}: ${(i+1)*500}MS`); | |
if (left[i]) { | |
console.log("-> Display", left[i]); | |
} | |
if (right[i]) { | |
console.log("-> Display", right[i]); | |
} | |
i++; | |
} | |
}, 500); | |
// Expected output: | |
// START | |
// RUN 0: 500MS | |
// -> Display left_one | |
// -> Display right_one | |
// RUN 1: 1000MS | |
// -> Display left_two | |
// -> Display right_two | |
// RUN 2: 1500MS | |
// -> Display left_three | |
// RUN 3: 2000MS | |
// -> Display left_four | |
// DONE! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment