SyntaxError:missing;在for-loop初始化器之后

时间:2016-10-06 06:04:27

标签: javascript

显示错过的错误;在for-loop之后。谢谢你的帮助。

 function checkAttempt(){
        var studentID = document.getElementById("studentID").value;
        var attempt = 0;

        for (attempt < 3 && studentID == localStorage.studentID){
            gradeTest;
            attempt = attempt + 1;
            localStorage.attempt = attempt;
            }       
        }

1 个答案:

答案 0 :(得分:1)

for替换为while

function checkAttempt(){
    var studentID = document.getElementById("studentID").value;
    var attempt = 0;

    while (attempt < 3 && studentID == localStorage.studentID{
        gradeTest;
        attempt = attempt + 1;
        localStorage.attempt = attempt;
    }       
}