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);
}
它是一个简单的函数,可以为输入的任何数字执行时间表。值-1将无效,我还要检查以确保用户输入有效数字。它不会运行。我一遍又一遍地检查了语法。这是我的第一个问题。
答案 0 :(得分:0)
您的while语句中有一个不匹配的(
:
while ((timesTable=prompt("Please enter a table to use",-1) != -1) //3 left parens and 2 right parens
将该行修改为:
while ((timesTable=prompt("Please enter a table to use",-1)) != -1)