简体   繁体   English

我正在尝试找出此Javascript代码出了什么问题

[英]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.

相关问题 我想弄清楚这里出了什么问题 - I am trying to figure out what is wrong here 我想弄清楚下面的 javascript 以及它的作用 - I am trying to figure out below javascript and what it does 我试图为我的训练营做一个测验,但我不知道代码有什么问题 - im trying to make a quiz for my bootcamp and i cant figure out what is wrong with the code 我无法弄清楚下面的javascript代码出了什么问题。 我尝试将函数存储在变量中 - I cannot figure out what is wrong with the javascript code below. I try to store a function in a variable 无法弄清楚我的JavaScript代码出了什么问题 - Can't figure out what is wrong with my JavaScript code 我有这个 python 代码,我试图将其转换为 javascript 但我似乎无法弄清楚是哪个 if 语句。 使用 - I have this python code that I am trying to turn into javascript but I cant seem to figure out which if statement. to use 试图找出此代码,javascript中的对象 - Trying to figure out this code, object in javascript 尝试使用Javascript调整点击文字的大小,我在做什么错? - Trying to resize text on click with Javascript, what am I doing wrong? 我正在尝试创建XML和XSL,但它给我一个错误,我不知道该怎么办 - I am trying to create an XML and XSL, but it is giving me an error that I can't figure out what to do 我想弄清楚如何使用 javascript 将字符串中的列转换为行 - I am trying to figure out how to convert columns in a string to row using javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM