Skip to content

Instantly share code, notes, and snippets.

@cupofcodeblog
Last active February 10, 2024 13:08
using guesses and usedKeys in post-game
export default function Wordle({ ..., showInstructions, showProgress}) {
...
let gameWasPlayedToday, gameData;
if (localStorage.wordlestruckLastGamePlayed) {
gameWasPlayedToday =
JSON.parse(localStorage.wordlestruckLastGamePlayed).gameNo === gameNo
? true
: false;
gameData = JSON.parse(localStorage.wordlestruckLastGamePlayed);
}
...
return (
...
{gameWasPlayedToday && (<>
<Grid
currentGuess={currentGuess}
guesses={gameData.guesses}
turn={gameData.turn}
/>
<Keypad usedKeys={gameData.usedKeys}
handleKeyupVirtual={handleKeyupVirtual} />
</>)}
{!gameWasPlayedToday && (<>
<Grid
currentGuess={currentGuess}
guesses={guesses}
turn={turn}
/>
<Keypad usedKeys={usedKeys}
handleKeyupVirtual={handleKeyupVirtual} />
</>)}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment