javascript interval fixed number of times

Solutions on MaxInterview for javascript interval fixed number of times by the best coders in the world

showing results for - "javascript interval fixed number of times"
Virgil
06 Jan 2017
1// This will be repeated 5 times with 1 second intervals:
2setIntervalX(function () {
3    // Your logic here
4}, 1000, 5);
Bastian
17 Jul 2018
1var x = 0;
2var intervalID = setInterval(function () {
3
4   // Your logic here
5
6   if (++x === 5) {
7       window.clearInterval(intervalID);
8   }
9}, 1000);