script.js
// When the user clicks on one of the choices, a series of actions happens. The srcElement event references which choice was clicked on, and given the variable clickID. An answer variable was created so I can see in the console log which choice was selected.  correctID variable was created to compare to the correctAnswer. If they match, then the score increments.
When the user clicks on one of the choices, a series of actions happens. The srcElement event references which choice was clicked on, and given the variable clickID. An answer variable was created so I can see in the console log which choice was selected.  correctID variable was created to compare to the correctAnswer. If they match, then the score increments.
When the user clicks on one of the choices a series of actions happens . The srcElement event references which choice was clicked on and given the variable clickID . An answer variable was created so I can see in the console log which choice was selected . correctID variable was created to compare to the correctAnswer . If they match then the score increments .
function clickedButton(clickevent) {
    if (currentQuestion < myQuestions.length) {
        var clickId = clickevent.srcElement.getAttribute('which');
        var answered = myQuestions[currentQuestion].choices[clickId];
        console.log("User clicked " + clickId + " which is " + answered);
        var correctId = myQuestions[currentQuestion].correctAnswer;
        var correctAnswer = myQuestions[currentQuestion].choices[correctId];
        console.log("Correct answer is: " + correctId + " which is " + correctAnswer);
        if (clickId == correctId) {
            alert("Correct!");
            score++
        } else {
            alert("Wrong")
        }
        currentQuestion++
    }
    if (currentQuestion < myQuestions.length) {
        displayQuestion();
    } else {
        alert("The quiz is complete. Your score is " + score + " out of 10");
    }
}
function clickedButton ( clickevent ) { if ( currentQuestion < myQuestions . length ) { var clickId = clickevent . srcElement . getAttribute ( 'which' ) ; var answered = myQuestions [ currentQuestion ] . choices [ clickId ] ; console . log ( "User clicked " + clickId + " which is " + answered ) ; var correctId = myQuestions [ currentQuestion ] . correctAnswer ; var correctAnswer = myQuestions [ currentQuestion ] . choices [ correctId ] ; console . log ( "Correct answer is: " + correctId + " which is " + correctAnswer ) ; if ( clickId == correctId ) { alert ( "Correct!" ) ; score ++ } else { alert ( "Wrong" ) } currentQuestion ++ } if ( currentQuestion < myQuestions . length ) { displayQuestion ( ) ; } else { alert ( "The quiz is complete. Your score is " + score + " out of 10" ) ; } }
When the user clicks on one of the choices, a series of actions happens.
When the user clicks on one of the choices a series of actions happens .