switch四则运算
时间: 2023-10-28 12:59:48 浏览: 77
四则运算计算
switch (operator) {
case '+':
result = num1 + num2;
break;
case '-':
result = num1 - num2;
break;
case '*':
result = num1 * num2;
break;
case '/':
result = num1 / num2;
break;
default:
console.log("Invalid operator");
}
阅读全文