Check out example codes for "loop through htmlcollection". It will help you in understanding the concepts better.
Code Example 1
<!DOCTYPE html>
<html>
<head>
<title>For loop for HTMLCollection elements</title>
</head>
<body>
<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++) {
console.log(collection[i]);
}
</script>
</body>
</html>
Learn ReactJs, React Native from akashmittal.com