There is an array with values, it is necessary to bypass the dom tree and fill the contents of elements with the child-elem class with elements from the array. It turns out that the last element of the array is added to all links. Tell me what I'm doing wrong.
<div class="container"> <div class="parent-elem"> <a class="child-elem"></a> </div> <div class="parent-elem"> <a class="child-elem"></a> </div> <div class="parent-elem"> <a class="child-elem"></a> </div> let arr = [1,2,3]; let div = '.child-elem', elems = document.querySelectorAll(div), elem, key; for (key in elems) { elem = elems[key]; for (let i = 0; i<arr.length; i++) { elem.innerHTML = arr[i] } }