Design comparison
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
Community feedback
- @Grego14Posted 5 months ago
š 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 helpful0@shivPostedPosted 5 months agoThanks, @Grego14 for your valuable insights I will make these changes in my code and that toggle one will help a lot, I first used a button for rules but replaced it with div because it was easy to style, but sure I neglected the accessibility of the user, thanks again for pointing that out, I will think about that keyboard event you mentioned
1
Please log in to post a comment
Log in with GitHubJoin 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