Pure JS - Reset attempts, after clicking


#1

Hi,
I need help. I created memory game. I would like to reset attempts. Every clicked pair of cards is equal to 1 attempt.
After clicking on restart button, I want to reset these attempts.

My code is here: https://codepen.io/Mdering/pen/KZbRed

I created function resetAttempts() {
let getAttempts = document.getElementsByClassName('attempts_plcholder')[0]
getAttempts.remove();
}

but it isn't giving proper result.

Morover // writeAttempts.innerHTML = 0; don't reset attempts.

Can you give me any hints?


#2

I've not checked in detail, but you do seem to be declaring attemptsCount twice; once in the initial variables at the top of the script, and then again in the renderAttempts() function - it doesn't look like you're assigning a number to it on the second occasion, neither does there seem to be anything to reset attemptsCount to zero as a part of the code attached to the reset button.


#3

Hi there deringmagdalena,

Ooooops, I have made an incorrect post. :eyebrows:

coothead


closed #4

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.