Skip to content
  • Unlock Pro
  • Log in with GitHub
Profile
OverviewSolutions
12
Comments
1

Gugg

@Gugg94130 points

I’m a mysterious individual who has yet to fill out my bio. One thing’s for certain: I love writing front-end code!

Latest solutions

  • Interactive Rating Component


    Gugg•130
    Submitted over 3 years ago

    1 comment
  • Huddle Landing Page


    Gugg•130
    Submitted over 3 years ago

    0 comments
  • Single Price Grid


    Gugg•130
    Submitted over 3 years ago

    0 comments
  • Four Card Feature Section


    Gugg•130
    Submitted over 3 years ago

    0 comments
  • Social Proof Section


    Gugg•130
    Submitted over 3 years ago

    0 comments
  • Profile Card


    Gugg•130
    Submitted over 3 years ago

    0 comments
View more solutions

Latest comments

  • Dummy_ken•180
    @DummyKen
    Submitted over 3 years ago

    Interactive Rating Component with JavaScript

    1
    Gugg•130
    @Gugg94
    Posted over 3 years ago

    Hey,

    1. I'd suggest using similar naming in HTML and JS, now you're mixing i.e. "numbers" and "ratings" for the same element, that's a bit confusing. I'd also be consistent in formatting and/or installing a code formatting plugin

    2. You've added the event listener for selecting a rating on the "ratings" container, which seems to add it to the container itself AND the items inside, resulting in being able to select the container if you click between the numbers, this is not what you want. Don't forget you also have "querySelectorAll" to select multiple elements, you should use this so you can select all the ratings items: => "const ratings = document.querySelectorAll('.number');" You can remove the selector for the container "numbers", you don't need that.

    3. Once you have all the separate numbers, you can add an event listener to all of them using a for-loop or forEach, you can look that up to figure it out.

    4. If you want to return a previously selected element back to it's original state you have to ask yourself "when will I reset the selected state?", the answer will be "when I select a number" => in your event listener, BEFORE you select a new rating, use a for-loop or forEach to go over all the numbers and remove the selected state, once they're removed everywhere you can safely add the selected state to the correct element

Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub