I'm trying to make hangaman game so if the user click the correct letter 'dont-draw' class will be added if he enter the wrong letter another class will added, but is seems this if condition never became false
else if(theClickedLetter !== wordGeuss){
e.target.classList.add('draw');
}
here is the code:
document.addEventListener('click', function(e) {
let theClickedLetter = e.target.textContent;
arrayGuess.forEach((wordGeuss, index) => {
if (theClickedLetter === wordGeuss) {
e.target.classList.add('dont-draw');
let n = Array.from(lettersGess.children);
n[index].textContent = theClickedLetter;
} else if (theClickedLetter !== wordGeuss) {
e.target.classList.add('draw');
}
Aucun commentaire:
Enregistrer un commentaire