Hello all! Looking forward to hear some feedback regarding the project and I have a question: What should I have used for my rating numbers (inside flex-group). I assume paragraph is not the (best) solution?
Tom Tillistrand
@TomTillyAll comments
- @amerrikaSubmitted almost 2 years ago@TomTillyPosted almost 2 years ago
Great job, amerrika!
To answer your question, I personally think radio button inputs within a
<form>
are the most appropriate. They visually don't present as standard radio buttons, but functionally they are the same: a group of related options with only one valid selection, that can be submitted with a button. Using these elements also does a lot of the functionality and accessibility work for you out of the box. Hope that's helpful!1 - @funupuluSubmitted about 2 years ago
Props to this guy. Programming is not easy. I recommend working with and following a code-along until you have enough skills to build on your own. https://www.youtube.com/watch?v=L9HElpQ82KA&list=PL5OIANLlPydqJJqvh1J1NCdNFaKZLoqaz&index=1
Below, why does btn appear twice and what is it doing? Is it calling itself? Recursion?
rating_btn.forEach( btn => { btn.addEventListener('click', handleRatingBtnClick) })
@TomTillyPosted about 2 years agoGood job funupulu!
Regarding your question, the
rating_btn
variable is a NodeList (similar to an array) of potential button elements. TheforEach
method loops through the NodeList and calls the callback functionbtn => { btn.addEventListener('click', handleRatingBtnClick) }
for each item in the NodeList.btn
is whatever button in the array the loop is currently on. Arrow function syntax was used here, but it could have also been written like this:rating_btn.forEach(function(btn) { btn.addEventListener('click', handleRatingBtnClick); });
In the function body, an event listener is being added to listen for a click on the button. When the button is clicked, the
handleRatingBtnClick
function is called. Hope that helps 🙂Marked as helpful0