-2

what is alternative of

if(s!=1||s!=2||s!=3)
 {

   alert("SUCCESS");
  }

It is not working. So Please suggest.

Kukic Vladimir
  • 1,010
  • 4
  • 15
  • 22

1 Answers1

3

It's very unlikely that you wanted:

 if(s!=1||s!=2||s!=3)

Since for all values of s, this is always true.

|| means that the expression is true if either the left side or right side is true.

Maybe you wanted it to be true if s was not 1, 2, or 3. Even though you use the word "or" in that sentence, in a logic expression, you say "s is not equal to 1 AND s is not equal to 2 AND s is not equal to 3"

If that's what you want, then the code is

if (s!=1 && s!=2 && s!=3)
Lou Franco
  • 87,846
  • 14
  • 132
  • 192