我的代码无效,我不知道为什么。我想做一个简单的事情,输入两个数字并打印它们的总和。 这是我的代码:
<script type="text/javascript">
var num1, num2, sum;
num1 = window.prompt("Enter number one");
num2 = window.prompt("Enter number two");
sum = num1 + num2;
window.alert(num1 + "+" + num2 + "=" + sum);
</script>
答案 0 :(得分:1)
<html>
<head>
<meta charset="UTF-8">
<title>Page91Ex6</title>
</head>
<body>
<script type="text/javascript">
var num1, num2, sum;
num1 = window.prompt("Enter number one");
num2 = window.prompt("Enter number two");
sum = parseInt(num1) + parseInt(num2);
window.alert(num1 + "+" + num2 + "=" + sum);
</script>
</body>
</html>