Check out example codes for "loop through htmlcollection". It will help you in understanding the concepts better.

Code Example 1

<!DOCTYPE html> 
    <title>For loop for HTMLCollection elements</title> 
    <h1 style="color: green">GeeksforGeeks</h1> 
    <b>For loop for HTMLCollection elements</b> 
    <p>This is paragraph 1.</p> 
    <p>This is paragraph 2.</p> 
    <script type="text/javascript"> 
        // get a HTMLCollection of elements in the page 
        let collection = document.getElementsByTagName("p"); 
        // regular for loop 
        for (let i = 0; i < collection.length; i++) { 

Learn ReactJs, React Native from