0

Third attempt.

I want a set of sentences to appear, one after the other and separated by 2 seconds. Then the process to begin again with a new set of sentences, until a set outcome is reached.

The code I posted previously was way too lengthy, and the nearest I can come to my desired outcome, which mimics my faulty code, is this:

 var counter;
 var postHere;
 var interval1;
 var timeout1;
 var timeout2;
 var timeout3;
 
 counter = 128;
 postHere = document.getElementById("comment");
 
 interval1 = setInterval(function() {
  timeout1 = setTimeout(function() {postHere.innerHTML = "<p>First sentence = " + counter + "</p>";
   timeout2 = setTimeout(function() {postHere.innerHTML = postHere.innerHTML + "<p>Second sentence = " + counter + "</p>";
    timeout3 = setTimeout(function() {postHere.innerHTML = postHere.innerHTML + "<p>Third sentence = " + counter + "</p>";}, 2000);
   }, 2000);
  }, 2000);
  counter = counter / 2;
  if (counter < 1) {clearInterval(interval1);}
 }, 2000);
<div id="comment"></div>

The linked duplicate is where I have derived the clears from, but this is an extension to that question.

Gazzieh
  • 53
  • 6
  • 1
    Can you create a [mcve]? – Roko C. Buljan Jun 13 '18 at 18:48
  • Please get rid of the introduction and get straight to the point, your question should clearly state 1. what you want to achieve(just the part you are failing) 2. what code you tried(minimal but enough to verify) 3. what error you are encountering. The code presented here is not minimal. – Munim Munna Jun 13 '18 at 21:43

0 Answers0