Languages
[Edit]
EN

JavaScript - create more complex objects eg object of objects

1 points
Created by:
AnnLen
11260

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);
}

 

Native Advertising
­čÜÇ
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

ÔŁĄ´ŞĆ­čĺ╗ ­čÖé

Join