我正在处理 switch 语句,并且一直在尝试使这里的代码正常工作,但它似乎没有输出正确的 console.log 案例字符串。
var user = prompt("What is your name?").toLowerCase();
switch(user){
case "luka":
console.log("What a beautiful name, my name is exactly the same :) Hi Luka! :D");
break;
case user.length > 10:
console.log("That's a long name!");
break;
case user.length < 4:
console.log("Not to be rude or impolite to you in any way, but your name is kinda short :( Not that it isn't cool or something :D");
break;
}
我试过像这样 (user).length < 4 那样在用户周围加上括号,但这不起作用,我的其他一些尝试也不起作用。有人知道如何正确实施吗?