I modified the quiz as you required.
game.css, note /* begin correct answer green flashing */
and /* end correct answer green flashing */
:
body {
color: #fff;
}
.choice-container {
display: flex;
margin-bottom: 0.8rem;
width: 100%;
border-radius: 4px;
background: rgb(18, 93, 255);
font-size: 3rem;
min-width: 80rem;
}
/* begin correct answer green flashing */
.choice-container.correct-flashing {
animation: green-flashing-ani 1s infinite;
}
@keyframes green-flashing-ani {
0% {
background: linear-gradient(32deg, rgba(11, 223, 36) 0%, rgb(41, 232, 111) 100%);
}
49.9% {
background: linear-gradient(32deg, rgba(11, 223, 36) 0%, rgb(41, 232, 111) 100%);
}
50% {
background: transparent;
}
100% {
background: transparent;
}
}
/* end correct answer green flashing */
.choice-container:hover {
cursor: pointer;
box-shadow: 0 0.4rem 1.4rem 0 rgba(6, 103, 247, 0.5);
transform: scale(1.02);
transform: transform 100ms;
}
.choice-prefix {
padding: 2rem 2.5rem;
color: white;
}
.choice-text {
padding: 2rem;
width: 100%;
}
.correct {
background: linear-gradient(32deg, rgba(11, 223, 36) 0%, rgb(41, 232, 111) 100%);
}
.incorrect {
background: linear-gradient(32deg, rgba(230, 29, 29, 1) 0%, rgb(224, 11, 11, 1) 100%);
}
/* Heads up Display */
#hud {
display: flex;
justify-content: space-between;
}
.hud-prefix {
text-align: center;
font-size: 2rem;
}
.hud-main-text {
text-align: center;
}
#progressBar {
width: 20rem;
height: 3rem;
border: 0.2rem solid rgb(11, 223, 36);
margin-top: 2rem;
border-radius: 50px;
overflow: hidden;
}
#progressBarFull {
height: 100%;
background: rgb(11, 223, 36);
width: 0%;
}
@media screen and (max-width: 768px) {
.choice-container {
min-width: 40rem;
}
}
game.js, I modified this forEach loop only:
choices.forEach(choice => {
choice.addEventListener('click', e => {
if (!acceptingAnswers) return
// get container of correct answer
const correctContainer = choiceContainers[currentQuestion.answer - 1];
acceptingAnswers = false
const selectedChoice = e.target
const selectedAnswer = selectedChoice.dataset['number']
// set class to apply according answer correct or not
let classToApply = selectedAnswer == currentQuestion.answer ? 'correct' : 'incorrect'
// correct answer?
if (classToApply === 'correct') {
// answer correct
// increment score only if there was no wrong answer
if (!correctContainer.classList.contains('correct-flashing')) {
incrementScore(SCORE_POINTS)
}
// after 1 sec:
setTimeout(() => {
// remove all classes previously set
choiceContainers.forEach(item => {
item.classList.remove('correct')
item.classList.remove('correct-flashing')
item.classList.remove('incorrect')
})
getNewQuestion()
}, 1000)
} else {
// answer incorrect
// make container of correct answer flash
correctContainer.classList.add('correct-flashing')
// accept answer again
acceptingAnswers = true
}
selectedChoice.parentElement.classList.add(classToApply)
})
})