mirror of
https://github.com/FranP-code/Hangman-game-with-React.git
synced 2025-10-13 00:42:32 +00:00
Victory and defeat logics done
This commit is contained in:
25
src/components/Scripts/CheckVictory.jsx
Normal file
25
src/components/Scripts/CheckVictory.jsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import Victory from "../Hangman/PuzzleWord/Victory";
|
||||
|
||||
const CheckVictory = (setIsVictory) => {
|
||||
|
||||
let allChildrenHaveText = true
|
||||
|
||||
const puzzleWord = document.getElementById('puzzleWord')
|
||||
const childrens = [...puzzleWord.children]
|
||||
|
||||
childrens.forEach(children => {
|
||||
|
||||
if (children.textContent === '') {
|
||||
allChildrenHaveText = false
|
||||
}
|
||||
});
|
||||
|
||||
console.log(allChildrenHaveText)
|
||||
|
||||
if (allChildrenHaveText) {
|
||||
|
||||
setIsVictory(true)
|
||||
}
|
||||
}
|
||||
|
||||
export default CheckVictory
|
||||
Reference in New Issue
Block a user