vendredi 10 juillet 2020

If statement to prompt a popup box when clicked

I am trying to create a popup whenever someone clicks on a button to alert "right answer" when btnthree == characterName but it seems not to be working. It alerts the else statement "no answer."

if (btnThree == characterName) {
           alert("right answer"); 
         } else {
           alert("No answer");
          {window.location.reload()}
         }}

 const btnThree = document.getElementById("btn-3");
       btnThree.textContent = nextItem();
       btnThree.addEventListener('click', optionTwo);

      document.getElementById("btn-4").textContent = shuffledQuestions[buttonFour];
      btnTwo.addEventListener('click', optionTwo);
      document.getElementById("next-btn").addEventListener('click', function (e){
      characterName.textContent= nextItem();
      
      document.getElementById("next-btn").addEventListener('click', nextItem);
        });
      });```

Help please?

Aucun commentaire:

Enregistrer un commentaire