I'm doing this little game,where you hear the random word from array and then click the card("container__item"). If the word matches the card, then card("container__item") becomes almost transparent and the game continues until there's no more words left. I have this code,but I can't figure out how to remove the audio from array if it matches the card. I
let gameContainer = document.querySelector('.game__container');
let audios = document.querySelectorAll('.audio');
let containerItem = document.querySelectorAll('.container__item')
let randomAudio;
function randomInteger(min, max) {
let rand = min + Math.random() * (max + 1 - min);
return Math.floor(rand);
}
gameContainer.addEventListener('click', playGame);
function playGame() {
const arr = Array.from(audios);
randomAudio = arr[randomInteger(0, arr.length - 1)];
randomAudio.play();
containerItem.forEach((a)=>a.addEventListener('click',guessCard));
function guessCard(){
if(randomAudio == this.querySelector('.audio')){
this.style.opacity = '0.3';
}
else{
audioFail.play();
}
}
}