Local storage for play again done

This commit is contained in:
2021-12-27 22:37:43 -03:00
parent 658c5b2419
commit 69cc467810
3 changed files with 51 additions and 10 deletions

View File

@@ -17,11 +17,30 @@ function main(game) {
disableEnterInputs(game)
addStartButtonFunctionality(game)
const data = localStorage.getItem('data')
if (data) {
const checkInputsResult = Object.values(JSON.parse(data))
localStorage.removeItem('data')
game(checkInputsResult, true)
}
}
function game() {
function game(checkInputsResult, replay) {
const checkInputsResult = checkInputs()
if (!checkInputsResult) {
checkInputsResult = checkInputs()
}
if (!replay) {
replay = false
}
console.log(checkInputsResult)
@@ -33,7 +52,7 @@ function game() {
hidePlayerSelection()
showTicTacToe()
gameLogic(checkInputsResult)
gameLogic(checkInputsResult, replay)
}
window.onload = () => main(game)