Is it possible to use ||
in JavaScript Case
function checkingForAB (data) {
var reply;
switch (data) {
case 'A'||'B':
reply = 'Yes';
break;
case 'D':
reply = 'No';
break;
default:
reply = 'No';
}
return reply;
}
I have not tried this before. So, I don't know what happens?
Thanks in advance.
try it like this instead...
function checkingForAB (data) {
var reply;
switch (data) {
case 'A':
case 'B':
reply = 'Yes';
break;
case 'D':
reply = 'No';
break;
default:
reply = 'Yes';
}
return reply;
}
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