[英]I am trying to figure out what is wrong with this Javascript code
function entertimesTable (timesTable,timesStart,timesEnd)
{
while (timesStart<=timesEnd)
{
document.write(timesTable + " * " + timesStart + "= " + timesTable*timesStart + "<br />");
timesStart++;
}
}
var timesTable;
while ((timesTable=prompt("Please enter a table to use",-1) != -1)
{
while (isNaN(timesTable) == true)
{
timesTable=prompt(timesTable + "is not a valid number, please retry", -1);
}
if (timesTable == -1)
{
break;
}
document.write("<br />The" + timesTable + " times table <br />");
entertimesTable(timesTable,1,12);
}
Its a simple function that does the times table for any number entered. 这是一个简单的功能,可以对输入的任何数字进行时间表。 A value of -1 will be invalid and I am also checking to make sure the user enter a valid number. 值-1将无效,同时我也在检查用户输入的数字是否有效。 It will not run. 它不会运行。 I have checked the syntax over and over again. 我已经一遍又一遍地检查语法。 This is my first question here. 这是我的第一个问题。
You have an unmatched (
in your while statement: 您有一个不匹配的(
在while语句中:
while ((timesTable=prompt("Please enter a table to use",-1) != -1) //3 left parens and 2 right parens
Modify that line to read: 将该行修改为:
while ((timesTable=prompt("Please enter a table to use",-1)) != -1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.