I have a for loop that needs to append a list item to two menus sharing the same class name. The problem is it will only append to one or the other if I reference the index of it or if I use index of I it will only append to the last item.
HTML
<ul class="menu">
<li>List One</li>
</ul>
<ul class="menu">
<li>List Two</li>
</ul>
JS
var menu = document.querySelectorAll('.menu');
var listItem = document.createElement('li');
for(i=0; i < menu.length; ++i){
menu[i].appendChild(listItem);
}
Is this another weird quirk of JS or am I just missing something?