Do not clone this repository because we will use a different template.
We recommend opening the React template
using a provisioning tool like Codespaces (recommended) or Gitpod. Alternatively, you can clone the GitHub repository on your local computer using the git clone
command.
This is the repository you need to open or clone:
https://github.com/4GeeksAcademy/react-hello
⚠ You will need to have Node.js installed if you do it locally, but all of that is already installed on Codespaces or Gitpod!
1// Example of card generation 2const cards = [ 3 { id: 1, image: 'url1', matched: false }, 4 { id: 1, image: 'url1', matched: false }, 5 // ... more cards 6];
1const [cards, setCards] = useState([]); 2const [flippedCards, setFlippedCards] = useState([]); 3const [matchedCards, setMatchedCards] = useState([]);
1useEffect(() => { 2 if (flippedCards.length === 2) { 3 const [firstCard, secondCard] = flippedCards; 4 if (firstCard.id === secondCard.id) { 5 setMatchedCards([...matchedCards, firstCard.id]); 6 } 7 setTimeout(() => setFlippedCards([]), 1000); 8 } 9}, [flippedCards]);
1const handleCardClick = (card) => { 2 if (flippedCards.length < 2 && !flippedCards.includes(card)) { 3 setFlippedCards([...flippedCards, card]); 4 } 5};
1.card { 2 transition: transform 0.6s; 3 transform-style: preserve-3d; 4} 5 6.card.flipped { 7 transform: rotateY(180deg); 8}
Score Counter: Implement a scoring system based on the number of moves or the time it takes the player to complete the game!
Difficulty Levels: Add different difficulty levels with more or fewer cards.
Sounds and Effects: Add sound effects when flipping cards or finding a pair!
Save Progress: Allow the player to pause and continue the game by saving the state in local storage.
Customizable Theme: Let the player choose between different themes or sets of images for the cards!
Multiplayer Game: Implement a mode where two players compete in turns and record who finds more pairs.
Explore different enhancements to make your memory game more interactive and entertaining!
In order to prepare better for completing this exercises, we suggest the following materials