Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Interactive rating component using JavaScript

@aboobaqr

Desktop design screenshot for the Interactive rating component coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


Writing the JavaScript code was a little challenging but I did it all myself

Community feedback

@Ratified

Posted

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 helpful

0

Please log in to post a comment

Log in with GitHub
Discord logo

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