@elaineleung
Posted
Hi Bernardo, well done in completing this! About your question, I'm not sure whether I fully understand it, but in any case, if you want to store the selected number in a variable, how about just using let
to assign a variable for storing the number, and whenever the button is clicked, the event listener can then reassign the variable to the newly selected number. I have a very simple CodePen of this challenge that you can have a look at and see whether that helps: https://codepen.io/elaineleung/pen/RwMqMxZ
Marked as helpful
@BernardoHollmann
Posted
@elaineleung Hi Elaine! Thank you for your comment! I saw your code and it is very clean and understandable. Congratulations! I see that you first created a "selected" variable and then used this variable to store the value from the selected btn. After that, you used this variable in a if statament to compare with the textcontent of the button. Very interesting! I believe I understand now and I will consider your solution for further projectes =)