I’m trying understand childNodes and trying to traverse the childNode.length, but when I log the function I just get the entire function written once more in console. But not the childNode length’s content. i.e [<p>,apple,</p>,<p>,orange,</p>]
HTML
<div id="nodes">
<p>apple</p>
<p>orange</p>
</div>
<div id="listofnodes"></div>
<script>
const Childnodes = document.getElementById('nodes').childNodes;
function Childnodes_list(){
let i = 0;
if (i <= childNodes.length, i++) {
Childnodes[i];
document.getElementById('listofnodes').innerHTML = (Childnodes[i]);
}
}
console.log (Childnodes_list);
</script>