Making choice (My first js project)

Solution retrospective
In js, can the code be more optimal?
Please log in to post a comment
Log in with GitHubCommunity feedback
- @martinablazheska
To avoid the duplicated code you currently have (i.e. a different page for each rating outcome), you can have a single html page where
<div id="msg">You selected 4 out of 5</div>is replaced by
<div id="msg">You selected <span id='result'>4</span> out of 5</div>Then, in your script.js, you can select the 'result' span by its id and change the inner HTML to show the result which the user clicked on.
To see what I mean , you can check out my solution of this exercise. https://www.frontendmentor.io/solutions/interactive-rating-component-pvk6CV-bFN
I hope this was helpful :)
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