Using Or (||) inside "if" statements

Hi, Does anyone know if there is a way to allow for 2 correct “if” answers (Warszawa and warszawa) by skipping (else if)?

  • Normal inefficient noob way:

    var answer = prompt("What is the capital of Poland?");
      if (answer == "Warszawa") {prompt("Exactly");
      }
        else if (answer == "warszawa") {prompt("Almost correct, 
        next time use a Capital letter when writing Warszawa");
        }
          else {prompt("Wrong, the correct answer is Warszawa");
          }
    
  • This is my unsuccessful idea:

var answer = prompt(“What is the capital of Poland?”);
if (answer == “Warszawa” || “warszawa”) {prompt(“Exactly”);
}
else {prompt(“Wrong, the correct answer is Warszawa”);
}

2 Likes

You’re so close…This is how you do it.

3 Likes

thanks @Bossman, that is exactly what you should try @FilipGuldhill.

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

Do you know what the characters on a windows keyboard is for the or symbol? I can’t seem to find the correct ones

1 Like

Is different in on each keyboard, mine is US distribution so for me is the shift+\. I dont know which could be for you.

Carlos Z.

Thanks, that worked.

1 Like