我刚开始学习 JavaScript,并且对 C# 有非常基本的了解。
尝试运行这段代码:
var number = parseInt(prompt("Enter a number:"));
switch (number) {
case number >= 1 && number <= 9:
alert("The number " + number + " is a single digit number.");
break;
case number >= 10 && number <= 99:
alert("The number " + number + " is a two digit number.");
break;
case number >= 100 && number <= 999:
alert("The number " + number + " is a three digit number.");
break;
case number >= 1000 && number <= 9999:
alert("The number " + number + " is a four digit number.");
break;
default:
alert("Your number has 5 or more digits.");
}
但在以下情况后它一直失败:
number <= 9
你们能帮我一下吗?
非常感谢!