mercredi 7 août 2019

Unable to convert if-else to a ternary

I am at a lost on how to change this if-else statement to a ternary

Directions: Convert the following if..else into a ternary within the provided name() function. Don't forget to continue to use the document.getElementById() statements within the if..else blocks.

function name() {
  let firstName;
  if (firstName === "John") {
    document.getElementById("demo").innerHTML = "Hello John!";
  }
  else {
    document.getElementById("demo").innerHTML = "Hello Human!";
  }
}

Aucun commentaire:

Enregistrer un commentaire