From f7c8d78092466e5d3b86787315dbd4539cd910a1 Mon Sep 17 00:00:00 2001 From: Isabela Hyeda Date: Mon, 9 Jan 2023 19:56:46 -0300 Subject: [PATCH] =?UTF-8?q?Ajuste=20na=20condi=C3=A7=C3=A3o=20de=20vit?= =?UTF-8?q?=C3=B3ria?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 6_PROJETO_SECRET_WORD/secretword/src/App.js | 24 +++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/6_PROJETO_SECRET_WORD/secretword/src/App.js b/6_PROJETO_SECRET_WORD/secretword/src/App.js index 2faa2ee..7cbf3a3 100644 --- a/6_PROJETO_SECRET_WORD/secretword/src/App.js +++ b/6_PROJETO_SECRET_WORD/secretword/src/App.js @@ -125,18 +125,20 @@ function App() { // check win condition useEffect(() => { - const uniqueLetters = [...new Set(letters)]; + if (letters.length > 0) { + const uniqueLetters = [...new Set(letters)]; - console.log(uniqueLetters); - console.log(guessedLetters); - - // win condition - if (guessedLetters.length === uniqueLetters.length) { - // add score - setScore((actualScore) => (actualScore += 100)); - - // restart game with new word - startGame(); + console.log(uniqueLetters); + console.log(guessedLetters); + + // win condition + if (guessedLetters.length === uniqueLetters.length) { + // add score + setScore((actualScore) => (actualScore += 100)); + + // restart game with new word + startGame(); + } } }, [guessedLetters, letters, startGame]);