Can someone explain me why answerEl is used instead of answerEls in line 172. Help me with my study thank you | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can someone explain me why answerEl is used instead of answerEls in line 172. Help me with my study thank you

https://code.sololearn.com/Wr3OObZyA3Jd/?ref=app

15th Sep 2022, 9:15 AM
Kuro Chi
Kuro Chi - avatar
2 Answers
+ 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
15th Sep 2022, 9:22 AM
Davinder Kumar
Davinder Kumar - avatar
+ 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) }
15th Sep 2022, 9:50 AM
Solo
Solo - avatar