DEV Community

Jennifer Tieu
Jennifer Tieu

Posted on

Self-Taught Developer Journal, Day 55: TOP Building Rock Paper Scissors UI cont.

Today I finished implement the JavaScript code. I ended up adding two conditionals for check if the game reached five rounds.

game function

Then tested the code and it worked like expected.
Working Game

I added in a window.confirm() method to prompt the user to play again once the game is over, but the I noticed there's a slight bug when the game reaches round 5.

window confirm bug

gameOver function

The round count would reach five, but then the confirm window would pop up before the DOM elements would update which is weird because I'm not calling the gameOver function until at least the round count equals five.

It might be because the roundNumber updates to five at the start of the function and the gameOver conditional is executing faster than the DOM elements. I need to spend some time thinking this through again.

Resources

The Odin Project
Revisiting Rock Paper Scissors

Top comments (0)