Memory Game

So,I have to make a memory game project for my scholarship. I made the HTML/CSS ,also,in JS, I added the on-click event handler to show cards, also, i added a shuffle method, so the card won’t be in the same position. Now, I need to add a script that lets you only click two cards then ,if they don’t match,they’re going back to no showing symbol,if they match,the “match” class is added,anyone has any ideea?

Why don’t you post the code that you have so far, and what you have tried for this last part. Then people can help you with any problems you might be having with your code. If you don’t know how to start the last script, try to break it down into smaller steps using pseudo code (words instead of JavaScript), then convert that into JavaScript.

This is the code i have and i really can’t find a way to add a logic for it to open 2 cards at once and if they match to remain like that…

Well, you dont want it to open two cards at once. You want it to trigger when a second card is revealed.
You’re doing this in pure javascript?
Consider this:
When you flip a card, how can you check how many cards are flipped right side up?
If you answered the previous question, you know which cards are currently flipped up. Do they match?
If they do match, let’s do something to them to mark them as matched, and not let them be flipped anymore. (Also don’t let them be counted in the first ‘how many cards are flipped up’ count)
If they don’t match, let’s turn them back down again.

Idk how to count how many are flipped,if they are flipped i’ll add a match class if not i’ll just toggle off the show/open classes

Here’s a hint.

Yea…well …i don’t really get it ,ik about that already,even used it…

Then you do know how to count how many are flipped.

What defines a flipped card?

1 Like

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