Design comparison
Solution retrospective
I need to improve in Javascript, I enjoy during this challenge
Community feedback
- @AdrianoEscarabotePosted almost 2 years ago
Hello glgaviria64, how are you? I truly loved your project's outcome, however I have some advice that I hope you'll find useful:
To avoid a big code, we can make some changes.
first we can use the same class on all the buttons:
<button class="btncard" id="1">1</button>
To get them all in
js
we will use this:const buttonCard = document.querySelectorAll(".btncard")
and then to add the events, we can use the
forEach
method since we have an array of elements, and in each element we will add a click event with the necessary functionality:buttonCard.forEach(element => { element.addEventListener("click", () => { calificacion = element.textContent; }); });
The remainder is excellent.
I hope it's useful. π
0 - @LagxyPosted almost 2 years ago
theres an issue when the user didn't select any number and it display undefined out of 5, i suggest you put the default value to 0.
0 - @VCaramesPosted almost 2 years ago
Hey there! π Here are some suggestions to help improve your code:
- The
figure
element is not needed β since there is nofigcaption
attached to it.
- The βicons/illustrationsβ in this component are purely decorative. β οΈ Their
alt tag
should be left blank and have anaria-hidden=βtrueβ
to hide them from assistive technology.
More Info: π
https://www.w3.org/WAI/tutorials/images/
- To ensure that the "rating buttons" are fully accessible π―, they need to be built using a
form
β οΈ and inside of it, there should be fiveinput radios
and eachinput
should have alabel
attached to it to make the buttons accessible. Finally wrap all theinputs
andlabels
inside afieldset
to prevent users from making more than one selection.
More Info: π
- Currently, users can submit without selecting a rating β οΈ. To fix this, you can do one of the following:
- Make the β5β rating the default rating.
- Create an error message, telling users they need make a selection.
- Disable the button until a selection is made.
- Your
CSS Reset
is being underutilized. π’ To fully maximize π― it, you will want to add more to it.
Here are some examples that you can freely use:
If you have any questions or need further clarification, feel free to reach out to me.
Happy Coding! πππͺ
0 - The
Please log in to post a comment
Log in with GitHubJoin 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