DEV Community

Jennifer Tieu
Jennifer Tieu

Posted on

6

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

Today I am still working on my JavaScript code.

I am trying to set up tracking the rounds. The game should stop when the round count reaches five. At first, I was putting a conditional to check the round count first when the button was pressed, but I realized an issue.

Round Condition

Assuming the round count is four, when the player presses the button and the condition where round equals five will not execute. However, when they round finishes then the round will update to five and they game should end. I could put the same condition at the end, but I don't really want to repeat myself in two places. I could try making a function or a loop? Maybe not a loop. A function might work.

I might try that and see.

Resources

The Odin Project
Revisiting Rock Paper Scissors

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post