Why is my code giving output 5 instead of 2? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3
2nd Jun 2020, 3:12 PM
Atharva Shrawge
Atharva Shrawge - avatar
2 Answers
+ 6
Same question asked and answered just today. There are 2 paragraph elements, plus 3 blank text element - before and after first paragraph, and one after the second paragraph. https://www.sololearn.com/Discuss/2326512/?ref=app
2nd Jun 2020, 3:23 PM
Ipang
+ 4
To add to Ipang 's answer: to get output of 2, use a.children instead of a.childNodes
2nd Jun 2020, 3:24 PM
Russ
Russ - avatar