EN
JavaScript - create more complex objects e.g. object of objects
1
points
Create object with array of strings (columns) and array of objects (users). Each user is described by id, name, age properties.
// ONLINE-RUNNER:browser;
var advObj = {
columns: ['ID', 'Name', 'Age'],
users: [
{ id: 1, name: 'Bob', age: 25 },
{ id: 2, name: 'Adam', age: 43 },
{ id: 3, name: 'Mark', age: 16 },
{ id: 4, name: 'John', age: 29 }
]
};
console.log(advObj.columns);
console.log('--------');
for (let user of advObj.users) {
console.log(user.id + ', ' + user.name + ', ' + user.age);
}