I am trying to display the values on the browser, but instead, it returns [object, object]. I would like the values to be displayed as: "1. Edward 2. John 3. Andy".
const person = [
{name: 'Edward'},
{name: 'John'},
{name: 'Andy'}
];
for ( let i = 0; i < person.length; i++ ){
var people = person[i].name;
}
function createListItems(arr) {
let list = '';
for (let i = 0; i < arr.length; i++){
list += `<li>${arr[i]}</li>`;
}
return list;
}
let html = `<ol>${ createListItems(person) }</ol>`;
document.querySelector('main').innerHTML = html;