Hello sir I'm practicing my vanilla javascript. I am trying to create a "Hangman Game" when the correct letters are clicked from the buttons.. You win. I have all these buttons in queryselector(letterA to letterZ).
The problem using this function.. the winAlert = visible implements when the letterS was clicked (last letter of "cautious").
So is there a way when you clicked all the letters of cautious in any order the winAlert.style.visibility = "visible" will be execute inside the function?
I've tried everything in the last hours.. buttons.forEach, slice etc. nothing works.
function youWonCautious() {
var buttons = [letterC, letterA, letterT, letterI, letterU, letterI, letterO, letterS]
for (var i = 0; i < buttons.length; i++) {
var button = buttons[0, 1, 2, 3, 4, 5, 6, 7];
button.onclick = function() {
winAlert.style.visibility = "visible"
}
}
}