mirror of
https://github.com/FranP-code/Hangman-game-with-React.git
synced 2025-10-13 00:42:32 +00:00
bk commit
This commit is contained in:
26
src/components/Scripts/CheckVictory.js
Normal file
26
src/components/Scripts/CheckVictory.js
Normal file
@@ -0,0 +1,26 @@
|
||||
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