Is there any way to make this work with a switch, syntactically?
switch(i){
case ('foo' || 'bar'):
alert('foo or bar');
break;
default:
alert('not foo or bar');
}
switch(i){
case 'foo':
case 'bar':
alert('foo or bar');
break;
case 'other':
default:
alert('other');
}
Note: "other" isn't required, I'm just showing that you can stack cases with default as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With