Skip to content

Instantly share code, notes, and snippets.

@cupofcodeblog
Created January 12, 2024 15:46
collect statistics
export default function Wordle({...}){
...
useEffect(() => {
...
if (isCorrect || turn > 5) {
...
if (!localStorage.wordlestruckStatistics) {
localStorage.wordlestruckStatistics = JSON.stringify([
...Array(7).fill(0),
]);
}
let objStatistics = JSON.parse(localStorage.wordlestruckStatistics);
let index = isCorrect ? turn : 0;
objStatistics[index] = Number(objStatistics[index]) + 1;
localStorage.wordlestruckStatistics = JSON.stringify(objStatistics);
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment