Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Request path contains unescaped characters
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Interactive rating component

Kinga 150

@K-Muzslay

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


My first challenge using JS. I appreciate any feedback.

Community feedback

Adriano 34,090

@AdrianoEscarabote

Posted

Hello Kinga, how are you? I truly loved your project's outcome, however I have some advice that I hope you'll find useful:

To make the submit button work only when the user selects a number, we can do this:

for (let i = 0; i < rating.length; i++) {
  rating[i].addEventListener('click', function () {
    a.textContent = rating[i].textContent + ' ';
    submitBtn.addEventListener('click', function () {
      ratingSection.style.display = 'none';
      thankSection.style.display = 'grid';
    });
  });
}

The remainder is excellent.

I hope it's useful. 👍

Marked as helpful

1

Kinga 150

@K-Muzslay

Posted

@AdrianoEscarabote Thank you very much for your suggestion to make my function better :) /to be honest I didn't think about that problem, my bad/ I tried to fix it before closely looking at your solution. I used an if statement for checking the length of the textContent, but after looking at yours, yes that is unnecessary in this case. :)

Thank you again :)

1

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