0
Can someone explain me why answerEl is used instead of answerEls in line 172. Help me with my study thank you
2 Respuestas
+ 3
answerEl is a list of items and answerEls is array which consists that items and to iterate over each item we are using forEach loop there to checked
+ 3
This is an enumeration of answerEls elements, which are passed to the function argument. You can give the argument a name at your discretion.
forEach() is an improved for() cycle in ES6.
answerEls.forEach(elem => {
if(elem.checked) {
answer = elem.id
}
})
Deprecated syntax:
function func(arg){
if(arg.checked) {
answer = arg.id
}
}
for(let el of answerEls){
func(el)
}