Design comparison
Solution retrospective
any feedback would be greatly appreciated regarding the most efficient use cases with javascript for this particular project. I definitely did violate the DRY(don't repeat yourself) rules here.
Community feedback
- @ThatDevDiazPosted over 1 year ago
Hey!
I noticed you labeled each individual number and applied a function to each different selection
One thing I would do to help with the dry principle is to just create a single function which will receive the user's input as a value and return this value so you can then call this function in a template literal and the result will be dynamic instead of statically creating the individual outcome for each different click. In this case, the user's input will only be recorded once the submit button is pressed. No need to record whats pressed every time because it really only matters once they hit submit.
The end result will be something like - ratingResult.textContent = "You've selected ${selectedButton()} out of 5!"
and of course, selectedButton will be whatever value the function returned. This way you only have to make the event listener for the "submit" button and not an event listener for every individual rating.
Marked as helpful1 - @itushPosted over 1 year ago
Congratulations on completing the challenge! π
Your solution looks nice to me :)
-Feel free to go through my solution to get some ideas about the JavaScript of the project.
I hope this helpsπ€
Happy hacking! ππ»
0
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