𝗗𝗮𝘆 𝟯𝟮 𝗼𝗳 𝗟𝗲𝗮𝗿𝗻𝗶𝗻𝗴 𝗠𝗘𝗥𝗡 𝗦𝘁𝗮𝗰𝗸
I built a Snake and Ladder game today.
This project required complex array manipulation and logic. I used HTML5, CSS3, and Vanilla JavaScript.
Yesterday I built Rock Paper Scissors. Today I moved to a 100-cell grid. This required tracking positions across a mathematical layout.
Here is how I built it:
- I used a loop to create the grid. I did not hardcode 100 divs.
- I used CSS Grid to create a 10x10 layout.
- I used a JavaScript object to manage ladders and snakes.
The object map links a trigger tile to a destination tile. This avoids long if-else statements.
Example map:
- Ladders: 4 to 14, 9 to 31, 28 to 84.
- Snakes: 17 to 7, 54 to 34, 98 to 79.
Managing spatial transitions on a dynamic interface taught me a lot about state management.
Source: https://dev.to/ali_hamza_589ec7b3eb6688d/day-32-of-learning-mern-stack-15o1