Last active
June 9, 2018 14:04
-
-
Save GitSquared/9c5c9fe5985a14c35e2773fc9a96ade8 to your computer and use it in GitHub Desktop.
Revisions
-
GitSquared revised this gist
Jun 9, 2018 . 1 changed file with 16 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -16,4 +16,19 @@ let x = setInterval(() => { } 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! -
GitSquared created this gist
Jun 9, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ 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);