How to use forEach function ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to use forEach function ?

I'm trying to console log the value of button when pressing it but it gives me a error instead, what is the problem here is the code for some clarification. https://code.sololearn.com/WKHH7L9NApu8/?ref=app

14th Dec 2020, 1:14 PM
Abderrahim Rhitrif
Abderrahim Rhitrif - avatar
3 Answers
+ 4
querySelector returns a single node, you can't use forEach on it. querySelectorAll returns a list of nodes, and you can use forEach on it.
14th Dec 2020, 1:18 PM
maf
maf - avatar
+ 2
14th Dec 2020, 1:20 PM
maf
maf - avatar
+ 1
maf thanks man 💛
14th Dec 2020, 1:19 PM
Abderrahim Rhitrif
Abderrahim Rhitrif - avatar