<script>
function Counter (a, b, c) {
var sum = 0;
if (c == 1) { sum = a + b; }
else if (c == 2) { sum = a - b; }
else if (c == 3) { sum = a * b; }
else if (c == 4) { sum = a / b; }
return sum;
}
var pop = parseInt(prompt(
'1.加法运算\n2.减法运算\n3.乘法运算\n4.除法运算\n5.退出\n请输入您的选项:'
));
while (pop != 5) {
var a = parseInt(prompt('请输入第一个数字'));
var b = parseInt(prompt('请输入第二个数字'));
var counter = Counter(a, b, pop);
alert(counter);
pop = prompt(
'1.加法运算\n2.减法运算\n3.乘法运算\n4.除法运算\n5.退出\n请输入您的选项:'
)
}
</script>