Why is my code giving output 5 instead of 2? | SoloLearn: Learn to code for FREE!

+3

Why is my code giving output 5 instead of 2?

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

6/2/2020 3:12:21 PM

Atharva Shrawge

2 Answers

New Answer

+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

+4

To add to Ipang 's answer: to get output of 2, use a.children instead of a.childNodes