Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted almost 4 years ago

Rock, Paper, Scissors Game with JavaScript and CSS Class Toggling

Aaron Romanick•270
@aaron-romanick
A solution to the Rock, Paper, Scissors game challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


How to Play

  • You pick a "token" to see if you beat the house.
  • Chances of winning are always 50%-50%; you will never tie.
  • You can switch between "normal" mode and "bonus" mode by clicking logo image
  • Both normal and bonus mode scores are saved in localStorage so they will persist on the next visit to the page

CSS

  • While there were a lot of colors included in the style guide, I had to guess some of them from the design screenshots (eg: edge of tokens, shadows, focus glow).
  • To accommodate CSS transitions, I have a lot of high specificity selectors, so I feel the CSS is kind of bloated, and any hints as to how to simplify it would be appreciated.
  • Since there are a lot of transitions, I included the will-change property, but I've also read this can put on a strain on resources. I didn't notice a drop in performance either with or without it, so maybe it would be better to go without?
  • For the rules dialog on big screens, I wanted it to appear in the middle of the page regardless of window size, but I could only get it to work by setting the elements top property and animating it. I know animating the top property requires a re-paint of the page and thus is not high-performance. If anyone can think of a way to get the rules dialog exactly centered on the page without using it, please let me know.
  • I had to figure out what the coordinates of the position of each tokens around a circle was using trigonometry and putting each final value in by hand. Would there be a better way to figure it out with the calc function?
  • I'm using quite a few CSS variables, but I feel like I could have done more to make it more DRY. If you have any suggestions, I'd love to hear them.
  • In Safari, the SVG images get really blurry when scaled; I looked around but couldn't find a solution that fixed it. Please let me know if there's anything I could have done!

HTML

  • since this isn't some article/typical HTML and has lots of interaction/animations, I was kind of stuck as to how to organize the HTML. Is there a better way to lay this out?
Code
Loading...

Please log in to post a comment

Log in with GitHub

Community feedback

No feedback yet. Be the first to give feedback on Aaron Romanick's solution.

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit all CSS, SCSS and Less files in your repository.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

How does the JavaScript validation report work?

When a solution is submitted, we use eslint to run an automated check on the JavaScript code.

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.