0

Here is my code that's not working.

var question2 = prompt("question inserted later?");
  if(question2 == "Yes" || "yes") {
    alert("answer1.");
  }
  if(question2 == "No" || "no") {
    alert("answer2.");
  }
  else(question2 != "Yes" || "yes" || "No" || "no") {
    alert("answer3.");
  }

My Javascript Console is telling me there issue is in the line starting with else and that there is an "unexpected token", referring to the brackets. I don't know what the issue is and I'm not sure if I'm using else() correctly.

Ruby
  • 35
  • 2
  • 1
    `if (question2 == "Yes" || question2 == "yes")` – Phil Nov 06 '20 at 00:36
  • 1
    `else` does not accept conditions nor should yours require any – Phil Nov 06 '20 at 00:38
  • Like this else(question2)? Because that isn't working. – Ruby Nov 06 '20 at 02:22
  • No, like `else { alert("answer3.") }`. Take a look at the documentation ~ https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else – Phil Nov 06 '20 at 02:23
  • You need to make your secondary conditions `else if` instead of just `if`. Here you go ~ https://jsfiddle.net/capLwtqu/2/ – Phil Nov 06 '20 at 02:27

0 Answers0