From 6a240ae689751dc490b1c54ab4d7fc70e0b988db Mon Sep 17 00:00:00 2001 From: prathoseraaj Date: Fri, 3 Oct 2025 14:56:44 +0530 Subject: [PATCH] fix: grid issues --- memory-game/components/MemoryGame.jsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/memory-game/components/MemoryGame.jsx b/memory-game/components/MemoryGame.jsx index cbf73bc3..7e643a11 100644 --- a/memory-game/components/MemoryGame.jsx +++ b/memory-game/components/MemoryGame.jsx @@ -19,14 +19,18 @@ const MemoryGame = () => { const [flipped, setFlipped] = useState([]); const [selectedPairs, setSelectedPairs] = useState([]); const [disabled, setDisabled] = useState(false); + const [error, setError] = useState(""); const [won, setWon] = useState(false); const handleGridSize = (e) => { - const size = parseInt(e.target.value); - if (2 <= size && size <= 10 && (size * size) % 2 === 0) { - setGridSize(size); - } + const size = parseInt(e.target.value); + if (2 <= size && size <= 10 && (size * size) % 2 === 0) { + setGridSize(size); + setError(""); + } else { + setError("Please enter a grid size where gridSize x gridSize is even (e.g. 2, 4, 6, 8, 10)"); + } }; const initializeGame = useCallback(() => {