Cannot read property length.
Код прилагаюdocument.addEventListener('DOMContentLoaded', function () {
function getAllNames(users) {
return users.map(function (user) {
let name = user.first_name;
return {
name: name,
length: name.length
};
});
}
getAllNames(users);
const usersListData = getAllNames(users);
const ulList = document.querySelector('.users-list');
usersListData.forEach(user => {
ulList.insertAdjacentHTML('beforeend', `<li class="user-info">User: ${user.name}, string length: ${user.length}</li>`);
});
});
let name = user.first_name;
return {
name: name,
length: name.length
};