JavaScript逻辑失败

JavaScript逻辑失败,javascript,logic,Javascript,Logic,我编写了一个从另一个站点改编的脚本,但逻辑失败: // read users file // from: https://code.tutsplus.com/tutorials/parsing-a-csv-file-with-javascript--cms-25626 $.ajax({ url: 'users.csv', dataType: 'text',

我编写了一个从另一个站点改编的脚本,但逻辑失败:

            // read users file
            // from: https://code.tutsplus.com/tutorials/parsing-a-csv-file-with-javascript--cms-25626
            $.ajax({
                url: 'users.csv',
                dataType: 'text',
            }).done(compareCredentials);
        }

        // function to read csv file data adapted from:
        // https://code.tutsplus.com/tutorials/parsing-a-csv-file-with-javascript--cms-25626
        function compareCredentials(data){
            var allRows=data.split(/\r?\n|\r/);
            console.log(allRows);
            var username=document.getElementById("username").value;
            var password=document.getElementById("password").value;
            var success=false;

            // skip row zero as it's the header row
            for (var oneRow=1; oneRow < allRows.length ; oneRow++) {
                var rowCells=allRows[oneRow].split(',');
                if (rowCells[0].value===username);{
                    if (rowCells[1].value===password);{
                        document.getElementById("loginForm").style.display="none";
                        msg="Username: " + username + "  Password: " + password;
                        console.log(msg);
                        msg="File Username: " + rowCells[0] + " File Password: " + rowCells[1];
                        console.log(msg)
                        success=true;
                    }
                }
            }
这也没什么区别(这就是为什么我把它们分解成不同的逻辑步骤)

我做错了什么


非常感谢。

答案是:

if (rowCells[0].value===username);{
应该是这样的:

if (rowCells[0]===username){

Appreciate the help guys.

“我做错了什么?”——从另一个站点改编脚本。编写您自己的代码,并编写您理解的代码。从阅读文档开始。我希望您能意识到,如果在用户浏览器上执行此代码,它可以很容易地规避。@BertrandMarron-谢谢Bertrand,但它本身并没有任何“功能性”。@Ivar-是的,我知道。该代码用于验证登录表单的学校练习。然而,虽然它可以用“硬代码”来完成,但不管它有多弱,我还是希望至少从一个文件中验证它。IF语句中的额外分号(括号前)。还没弄清楚怎么做!作品
if (rowCells[0]===username){

Appreciate the help guys.