I am trying to generate a list of names from an Array with this piece of script
const names = ["John", "Hanna", "Luis", "Halley", "Maive"]
const list = document.getElementById('my_list')
names.forEach((name) => {
let li = document.createElement("li")
li.innerHTML = name
list.appendChild(li)
})
and this html
<ul id="my_list"></ul>
but its not working. What am I doing wrong?