Is there a concise or better way to write this condition without having to use so many ||
.
if (myVar != 'A' && myVar != 'B' && myVar != 'C'){
...
}
Is there a concise or better way to write this condition without having to use so many ||
.
if (myVar != 'A' && myVar != 'B' && myVar != 'C'){
...
}
You can also express it like an array,
if (!['A', 'B', 'C'].includes(myVar)) {
// if myVar is none of the values in the array
}
edit: added negation to grab the opposite case as your example