我正在为计算器编写代码,但出现错误“意外标识符”,我不知道出了什么问题。代码行是 alert(“欢迎来到乘法网站!”。
我不知道怎么了。
<head>
<title>Multiplication Table</title>
<script type="text/javascript">
alert("Welcome to the multiplication website!")
var rows = prompt("What is your first number?")
var cols = prompt("What is your second number?")
output = rows * cols
if rows isNaN()
then output = Error: Not a Number
document.write(output);
</script>
</head>
<body>
</body>
</html>
I expected it to not have errors, then there were errors.
答案 0 :(得分:1)
您有一个看起来像是伪伪代码的小代码-试试这个:
if (isNaN(rows)) alert("Error: Not a Number");