So I´m following a tutorial on Youtube which by the way is from FreeCodeCamp, and is about making a card memory game on JS. https://www.youtube.com/watch?v=ZniVgo8U7ek
Everything in my code semms to be working fine until I reach the minute 22:50 where it starts to put the conditional:
if(frontCard.dataset.framework === backCard.dataset.framework){
frontCard.removeEventListener("click", changed);
backCard.removeEventListener("click", changed);
} else {
frontCard.classList.remove('flip')
backCard.classList.remove('flip')
}
Once I update my code with that, I go click one of the cards and the error: “Cannot read property ‘dataset’ of undefined” appears. While in the video it doesn´t. Also, it doesn´t let me click more than one card before it resets again. While in the video it can click two cards. I seriously don´t understand what is happening.
This is the full code: https://codepen.io/Assblack/pen/jjrqrx Note that since I´m developing in my “local machine” the images won´t load, but you can see the error if you open the console, and hit any of the cards. An error with the text “Cannot read property ‘dataset’ of undefined” should appear.