What do you think would be the output? [HTML Collection | NodeList]
@Yomesh Gupta
Suppose we have the following HTML structure.
<div>Hello World</div>
<div>How are you?</div>
What would be the output if we run the following code snippet?
var divs = document.getElementsByTagName("div");
for ( var i = 0; i<divs.length; i++ ) {
divs[i].appendChild(document.createElement("div"));
}
console.log(divs.length);
Option 1
1
Option 2
2
Option 3
Infinite
Option 4
Error