@Bluz0Submitted 12 months ago
In js, can the code be more optimal?
In js, can the code be more optimal?
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 :)