Bug with "dataset" property in a memory card game

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 {

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.

You only assign this to frontCard if flipped is false and you only assign this to backCard if flipped is true. The problem is your if statement checks both frontCard and backCard, but one of these will be undefined by the very nature of the previous if statement logic.

Thanks, I just realized i put this.classList.toggle(‘flip’) instead of this.classList.add(‘flip’). I changed now and functionality seems to be working like it should although the error still appears.

What you talking about I get what you mean although that´s how she does it in the tutorial.