Rock, Paper, Scissors game

Solution retrospective
I am proud to have achieved what I hoped in the project The changes I would make next time are to improve or optimize the code 😄😄
What challenges did you encounter, and how did you overcome them?The most challenging part was to display user's and computer's choices on the viewport I achieved it by using insertAdjacentHTML method
What specific areas of your project would you like help with?I would like to get help with how I can optimize my code
Please log in to post a comment
Log in with GitHubCommunity feedback
- @Grego14
👋 Hello! 🎉 Congratulations on completing the challenge! 🎉
Use ids to get the elements in the JavaScript code.
To avoid using a lot of eventListeners you can use 👉 Event Delegation and this would optimize the code and make it more readable.
Use semantic html tags, you're using a
div
element for the rulers button when you could use abutton
element and that causes that users are not be able to focus on the element using the keyboard.add the
tabindex='0'
attribute to all the choice--icon so that you can focus an option using the keyboard and add a keydown event for select an option using keys likeEnter
orSpace
.To avoid repeating the code in the eventListener of the closeRuleBtn and the rulesBtn you can do something like this:
function handleButtons(){ rulesOverlay.classList.toggle('hidden') bodyOverlay.classList.toggle('hidden') }
The classList interface toggle method removes or adds the class depending on whether it contains it or not.
I hope this helps! 😁
Marked as helpful
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