I have array of objects and i try to create the table (tr/td) with vanilla javascript.
Objects haven’t the “number” key. I don’t know how add the numbers to table.
Github repo: https://github.com/HikkiYarik/TaskList
dataUsers.js and renderUsers.js
I was try to create in getUsers()
function keys() {
const keys = Object.keys(users);
for (key in keys) {
return key;
}
}
and add keys() to newObj
users.forEach((obj) => {
const newObj = {
[map[0]]: `${obj._id}`,
[map[1]]: `${obj.name}`,
[map[2]]: `${obj.isActive}`,
[map[3]]: `${obj.balance}`,
[map[4]]: `${obj.email}`,
// [map[5]]: keys(),
};
newUsers.push(newObj);
});
and other similar methods, but no.
Result: the number in table have or every zero if
function keys() {
const keys = Object.keys(users);
for (key in keys) {
return key;
}
}
or every 2(length of my array of objects) if
function keys() {
const keys = Object.keys(users);
for (key in keys) {}
return key;
}
pls help