Reputation: 309
This question is Javascript-based but applies to logical operation in general
take the code example
if (baseText[i] == "."){
/*splice array*/;}
if (baseText[i] == "!"){
/*splice array*/}
if (baseText[i] == "?"){
/*splice array*/}
outputs what I want, but the following
if (baseText[i] == "." || "!" || "?"){
/*splice array*/}
should do the same, but doesn't. Forgive me, but my understanding of OR operation is that as long as one of the statements is true, the entire boolean value is True
no matter how many operands I use. Am I getting it wrong in theory, or wrong in practice?
If it means anything I'm also iterating this "array.length" times
Upvotes: 1
Views: 147
Reputation: 48972
if (baseText[i] == "." ||baseText[i] == "!" ||baseText[i] == "?"){
Upvotes: 2