samedi 28 août 2021

Unable to make a timer stop.. (js)

hi im doing a quiz app and i want it to count 10 sec for example and then go to another question but when I try to do: if(document.getElementById("timer_sec").innerHTML ==0)..... it doesnt work.

HTML":
<h1 class="hud-main-text" id="timer_sec">
 10
</h1>
js:
startGame = () => {
  document.getElementById("timer_sec").innerHTMl=10;
  questionCounter = 0;
  score = 0;
  availableQuesions1 = [...questions1];
  availableQuesions2 = [...questions2];
  availableQuesions3 = [...questions3];
  availableQuesions4 = [...questions4];

  setInterval(
    () => document.getElementById("timer_sec").innerHTML--,
    1000
  );
  getNewQuestion();
};```



Aucun commentaire:

Enregistrer un commentaire