0
var texts = ["exist", "real", "hello", "nope", "yellow"];
var count = 0;
function changeText() {
    $("t").text(texts[count]);
    count < 4 ? count++ : count = 0;
}
setInterval(changeText, 100);

I have this line of code were the text changes every 100ms. How can I make the setInterval pause every x seconds for x seconds and then resume and do it all over again? Thanks

Adrian Gonzalez
  • 737
  • 1
  • 7
  • 20
  • 1
    Use `setTimeout()` instead and have it call itself, this way you can change the time on the next call easily. – Spencer Wieczorek Oct 05 '16 at 23:17
  • @SpencerWieczorek is right. There's a few other answers to this exact question on SO. For example, [here](http://stackoverflow.com/questions/7279567/how-do-i-stop-a-window-setinterval-in-javascript) or [here](http://stackoverflow.com/questions/1191865/code-for-a-simple-javascript-countdown-timer) – chazsolo Oct 05 '16 at 23:23

0 Answers0