added local storage for stats in wordle so it dont go once i refresh!
This commit is contained in:
parent
854594a980
commit
a76341fe8b
1 changed files with 18 additions and 1 deletions
|
@ -87,7 +87,7 @@ export function newGame() {
|
||||||
function GameWin() {
|
function GameWin() {
|
||||||
alert("You win!");
|
alert("You win!");
|
||||||
data.value[WordLegnth.v].push(words.v.length);
|
data.value[WordLegnth.v].push(words.v.length);
|
||||||
|
localStorage.setItem("WordleGamesData", JSON.stringify(data.value));
|
||||||
newGame();
|
newGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,3 +207,20 @@ export let data = $state({
|
||||||
10: [],
|
10: [],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let WordleGamesData = localStorage.getItem("WordleGamesData") || "";
|
||||||
|
|
||||||
|
if (WordleGamesData == "") {
|
||||||
|
data.value = JSON.parse(WordleGamesData);
|
||||||
|
} else {
|
||||||
|
data.value = {
|
||||||
|
3: [],
|
||||||
|
4: [],
|
||||||
|
5: [],
|
||||||
|
6: [],
|
||||||
|
7: [],
|
||||||
|
8: [],
|
||||||
|
9: [],
|
||||||
|
10: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue