Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Christopher Lebbano
Christopher Lebbano
15,338 Points

Can anyone critique and possible help me with this mini game I'm making? jQuery (Long post, sorry).

Hello,

I'm about halfway through the jQuery basics videos and I wanted to test myself and see if I could solve a new problem, so I created a matching game. Earlier I asked a question about my game located here:

http://www.chrislebbano.com/game.html

Now the game is almost complete, but I've been banging my head against the wall with the last problem I can't solve.

Before I explain my last problem, here are the problems I've solved:

Randomly generate an image from a pool of 6 animal images across 12 flex box items, making sure that there are exactly 2 copies of each image for a total of 12.

Created another image ( a "?" image ) to sit in place of all the animal images until clicked to reveal the animal.

After exactly 2 animals are shown, the third click (on any item) will convert all of the items back to the "?" image.

Added a refresh button to re-randomize the animals.

Here's the problem I can't solve:

I want the game to know when two animals match, and then leave those animals visible no matter what. I have figured out how to compare them, I just can't come up with a solution to keep them visible. I even tried flat out removing the elements from the HTML, which does work until you start playing the game again, on the next 3rd click (whether the animals match or not) all of the elements somehow come back (including the already found animals which are then converted back to a "?").

I do not have the code anymore that does the .remove() or the comparing of the images, I got frustrated and removed it all which I wish I didn't so you could see if you wanted.

Anyway, any ideas on how I might be able to remove the found animals or keep them visible? I am happy with what I've accomplished so far and won't beat myself up too bad if I can't finish my own challenge.