1.实现两个数字的加减乘除
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
let num1 = prompt('请输入第一个数字:')
let fh = prompt('请输入符号')
let num2 = prompt('请输入第二个数字:')
switch(fh) {
case '+':
alert(parseFloat(num1) + parseFloat(num2));
break;
case '-':
alert(num1 - num2);
break;
case '*':
alert(num1 * num2);
break;
case '/':
alert(num1 / num2);
break;
}
</script>
</body>
</html>
版权声明:本文为qq_45579661原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。