assets/js/app.js
// This function handles an incorrect answer
This function handles an incorrect answer
This function handles an incorrect answer
function logIncorrectAnswer(target) {
    disableChoices();
    target.classList.add('btn-danger');
    wrongSound.play();
    if (timeLeft > 5) {
        timeLeft += -5;
    }
    var options = document.querySelectorAll('.choice');
    for (var i = 0; i < options.length; i++) {
        if (options[i].children[0].textContent == currentQuestionInfo.answer) {
            options[i].children[0].classList.add('btn-success');
        }
    }
    nextQuestion();
}
function logIncorrectAnswer ( target ) { disableChoices ( ) ; target . classList . add ( 'btn-danger' ) ; wrongSound . play ( ) ; if ( timeLeft > 5 ) { timeLeft += - 5 ; } var options = document . querySelectorAll ( '.choice' ) ; for ( var i = 0 ; i < options . length ; i ++ ) { if ( options [ i ] . children [ 0 ] . textContent == currentQuestionInfo . answer ) { options [ i ] . children [ 0 ] . classList . add ( 'btn-success' ) ; } } nextQuestion ( ) ; }
This function handles an incorrect answer
This function handles an incorrect answer
// Disable the choices so user doesn't accidentally hit another button // Play sound // Deduct some time from the timer but only if there are more than 5 seconds left //Let's also highlight what the correct answer was by looping all the choices until we find the one that matches the answer