I'm using a forEach()
to iterate through an array. If I console.log()
it, the correct objects appear in the console, but if I try to append via innerHTML
, it just shows undefined
on the page where the objects should be. Can anyone help me?
const phoneNos = () => {
dBase.name.phones.forEach(phone => {
document.querySelectorAll('.contacts').innerHTML += '<span class="pnumber">' + phone + '</span>';
console.log(phone);
})
}