以下代码是否正确:
var user = prompt("Is programming awesome?").toUpperCase();
switch (user) {
case 'HELL YEAH' || 'YES' || 'YEAH' || 'YEP' || 'YEA':
console.log("That's what I'd expected!");
break;
case 'KINDA'||'CANT SAY':
console.log("Oh, you'd like it when you'll be a pro!");
break;
case 'HELL NO'||'NO'||'NAH'||'NOPE'||'NA':
console.log("You can't say that!");
break;
default:
console.log("Wacha tryna say mate?");
break;
}
Run Code Online (Sandbox Code Playgroud)
我尝试过这个.但它没有按照我的意愿行事.如果输入是'地狱没有'或'地狱是的',它运作良好,但所有后来的字符串都被忽略了!