<div id="list">
<h2>Animals</h2>
</div>
html, body {
height: 100%;
}
body {
display: grid;
justify-content: center;
align-content: center;
}
const animals = ['cat', 'dog', 'mouse', 'cow', 'horse', 'duck']
const items = []
for (const animal of animals) {
items.push(`<li>${animal}</li>`)
}
const list = `
<ul>
${items.join('')}
</ul>`
const $list = document.getElementById('list')
$list.innerHTML = $list.innerHTML + list
This Pen doesn't use any external JavaScript resources.