Submitted over 1 year ago
Interactive rating component using JavaScript
@aboobaqr
Design comparison
SolutionDesign
Solution retrospective
Writing the JavaScript code was a little challenging but I did it all myself
Community feedback
- @RatifiedPosted over 1 year ago
Hello @aboobaqr
You did a really good job on this. Wow.
However, instead of selecting all the stars manually in your script, you can use a for loop to iterate through the whole list, here's how:
const stars = document.querySelectorAll('.rating-btn a'); stars.forEach(function(star) { star.addEventListener('click', function(){ //Implement your logic here }) });
With this you'll achieve the same functionality but with less javascript code. I hope this helps.
Happy coding man.
Marked as helpful0
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