Quantcast
Channel: Comparing strings with logical operators in an IF statement - Stack Overflow
Browsing latest articles
Browse All 4 View Live

Answer by dahui for Comparing strings with logical operators in an IF statement

Try:else if (choice1 !== "rock" || choice1 !== "paper" || choice1 !== "scissors")Your statement doesn't compile as "choice1 not equal to rock, paper, or scissors."The compiler reads it as:choice1 not...

View Article



Answer by Neil for Comparing strings with logical operators in an IF statement

// ...else if (choice1 !== "rock" || choice1 !== "paper" || choice1 !== "scissors") { return "Your only options are rock, paper, or scissors you friggin plebian!";} // ...Boolean expressions don't read...

View Article

Answer by user5398447 for Comparing strings with logical operators in an IF...

else if (choice1 !== "rock" || "paper" || "scissors") should be:else if (choice1 !== "rock" || choice1 !== "paper" || choice1 !== "scissors")

View Article

Comparing strings with logical operators in an IF statement

I am trying to figure out how to compare strings within an if statement. Most of my code can be ignored, but is there for context. I am trying to add a message to my simple rock, paper, scissors game...

View Article
Browsing latest articles
Browse All 4 View Live




Latest Images