@ThatDevDiaz
Posted
Hey!
I noticed you labeled each individual number and applied a function to each different selection
One thing I would do to help with the dry principle is to just create a single function which will receive the user's input as a value and return this value so you can then call this function in a template literal and the result will be dynamic instead of statically creating the individual outcome for each different click. In this case, the user's input will only be recorded once the submit button is pressed. No need to record whats pressed every time because it really only matters once they hit submit.
The end result will be something like - ratingResult.textContent = "You've selected ${selectedButton()} out of 5!"
and of course, selectedButton will be whatever value the function returned. This way you only have to make the event listener for the "submit" button and not an event listener for every individual rating.
Marked as helpful
@vintech05
Posted
@ThatDevDiaz nice one man, thanks for dropping by!