@AdrianoEscarabote
Posted
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. π