dimanche 5 septembre 2021

Im trying to compare two variable in javascript

It will have one of the variables defined and the other is defined when you typed if what you typed is the same it has the variable it says correct word and if they are not the same it says an incorrect word. My problem is that always say an incorrect word

function wordcompare() {
  var word1 = "word";
  var typed = document.getElementById("word");

  if (typed === word1) {
    alert("Correct word");
  } else {
    alert("Incorrect word");
  }
}

Aucun commentaire:

Enregistrer un commentaire