From a76341fe8b20f77bcc2199ac44a1335c5b2900ab Mon Sep 17 00:00:00 2001 From: RezHackXYZ Date: Sun, 4 May 2025 09:58:43 +0530 Subject: [PATCH] added local storage for stats in wordle so it dont go once i refresh! --- src/wordle/logic.svelte.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/wordle/logic.svelte.js b/src/wordle/logic.svelte.js index 70ec5ba..b40aa7f 100644 --- a/src/wordle/logic.svelte.js +++ b/src/wordle/logic.svelte.js @@ -87,7 +87,7 @@ export function newGame() { function GameWin() { alert("You win!"); data.value[WordLegnth.v].push(words.v.length); - + localStorage.setItem("WordleGamesData", JSON.stringify(data.value)); newGame(); } @@ -207,3 +207,20 @@ export let data = $state({ 10: [], }, }); + +let WordleGamesData = localStorage.getItem("WordleGamesData") || ""; + +if (WordleGamesData == "") { + data.value = JSON.parse(WordleGamesData); +} else { + data.value = { + 3: [], + 4: [], + 5: [], + 6: [], + 7: [], + 8: [], + 9: [], + 10: [], + }; +}