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

@adrianna-thomas

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


Did I use the best practice for my functions? I selected by element ID, should I have used classes instead or querySelectorAll?

Community feedback

Jorge 130

@JorgeIturrieta

Posted

Hi Adrianna!! Good Job! Offcourse you can selected by element id.

A little detail about your code :

    button.addEventListener("click", clickRatingBtn);  
 submitRatingBtn.addEventListener("click", ratingSubmit);
});

In every loop of forEach you are assigning the same event for submitRatingBtn element : submitRatingBtn.addEventListener("click", ratingSubmit);

So you can move this line and put it outside

    button.addEventListener("click", clickRatingBtn); 
});
 submitRatingBtn.addEventListener("click", ratingSubmit);

On the other hand the card must be centered.

You can do that in your main tag instead container class.

     display: flex;
     justify-content: center;
     align-items: center;
     min-height: 100vh;

I hope you are well and keep it up !

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