function Count(numberOne, numberTwo) {
this.numberOne = numberOne;
this.numberTwo = numberTwo;
this.act = function(sign) {
if (sign == '+') {
return parseInt(numberOne) + parseInt(numberTwo);
} else if (sign == '-') {
return parseInt(numberOne) - parseInt(numberTwo);
} else if (sign == '*') {
return parseInt(numberOne) * parseInt(numberTwo);
} else if (sign == '/') {
return parseInt(numberOne) / parseInt(numberTwo);
}
}
}
function input(sign) {
var count = new Count(prompt('请输入第一个数'), prompt('请输入第二个数'));
alert('计算结果为' + count.act(sign));
}
out: while (true) {
JS基础算法(弹窗计算器、猜数字、秒杀倒计时、不重复数组、字符查找、字符出现次数统计)
最新推荐文章于 2022-08-30 18:13:33 发布