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
Not Found

Submitted

Interactive rating component Solution

@surajnaveen

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


This is my frist challange in Frontend mentor.

Community feedback

P

@unachoza

Posted

Hi Suraj,

I looked at your code, although the functionality is achieved, you have 5 functions that are essentially the same. You can make this much DRY-er by writing a function with event target as the variable! Try adding just one event listening on all your mark <span>s

*function: *

const selectRating = (e) => {
    styleSelector();
    let mark = e.target.id
    let markValue = e.target.innerHTML
    mark.classList.add("rateSelect")
    rate.innerHTML = `you selected ${markValue} out of 5`;
}

add eventlistener to all marks:

allMarks.addEventListener("click", selectRating(e))

hope this helps!

Marked as helpful

1
Oficial51 270

@oficial51

Posted

I would advise you to make it responsive😅. However nice job!

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