vendredi 30 juin 2017

My JavaScript code is not working properly

The code works as it is supposed to until I enter my real age as it says "At that age you would be dead" even if I enter 14. So it wont matter what digits I enter, it will still return the same thing

var age = [""];

/* Our function that is supposed to do all the magic */
function setAge() {
  /* Declairing the usersage-variable */
  var inputage = document.getElementById("input").value;

  /* If inputage isn't a number */
  if (isNaN(inputage)){
    alert("Your age must be a number");
    return false;
  }
  /* Testing if the age is higher than 115 */
  else if(inputage => 115) {
    alert("At that age you would be dead");
    return false;
  }
  /* Set the age equal to the value of the users input */
  age[0] = inputage;
  document.getElementById("output").value = age[0];
}

Aucun commentaire:

Enregistrer un commentaire