DEV Community

Jennifer Tieu
Jennifer Tieu

Posted on

5

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

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more