显示错误,如遗失; for循环之后。感谢您的帮助。

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

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

最佳答案

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;
    }
}

09-17 04:30