如何在JavaScript中修复“意外标识符”

时间:2019-05-05 08:05:12

标签: javascript html

我正在为计算器编写代码,但出现错误“意外标识符”,我不知道出了什么问题。代码行是 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.

1 个答案:

答案 0 :(得分:1)

您有一个看起来像是伪伪代码的小代码-试试这个:

if (isNaN(rows)) alert("Error: Not a Number");