Building a card matching game, full code here https://codepen.io/3noki/pen/xjyErQ
I am trying to assign the event of turning a card over to a list/array, or a variable I guess, so I can check if it matches the next event of turning a second card over. But, this example, is resulting in errors, was placed this in the function openedCards().
let card1 =  $(event.target).toggleClass('open show');
If there is a better method for matching a value to a later value I haven't learned it yet, but this is what I currently know.
Also, I have implemented a counter, which should increment to a value of 1, then next event to a value of 2, and if they don't match, reset the both cards, I will be able to test it after this first part works, but that is listed in the function openedCards().
I think the biggest thing I am struggling with is specifying or saving the 1st and 2nd events from the DOM or figuring out how to reference this event as in an array[this event].
I've looked at some other examples like below but have been unsuccessful with trying those.
Excerpt of the code
function cardFlip(event) { 
    $(event.target).toggleClass('open show') 
    openedCards();
} 
function openedCards(i) { 
    if (openedCardsList.length === 0) {
        openedCardsList.push(i); 
         let card1 = $(event.target).toggleClass('open show');
    } else if (openedCardsList.length === 1) { 
        openedCardsList.push(i); 
        let card2 = $(event.target).toggleClass('open show');
    } else {
        openedCardsList = []; 
        cardFlip(card1);  
        cardFlip(card2);
    }
}
    
function cardFlip(event) { $(event.target).toggleClass('open show') openedCards(); } function openedCards(i) { if (openedCardsList.length === 0) { openedCardsList.push(i); let card1 = $(event.target).toggleClass('open show'); } else if (openedCardsList.length === 1) { openedCardsList.push(i); let card2 = $(event.target).toggleClass('open show'); } else{ openedCardsList = []; cardFlip(card1); cardFlip(card2); }