Multidimensional objects in JavaScript

Not only arrays, but also objects can be multidimensional, here is an example:

let obj = { a: { key1: 'a1', key2: 'a2', key3: 'a3', }, b: { key1: 'b1', key2: 'b2', key3: 'b3', }, c: { key1: 'c1', key2: 'c2', key3: 'c3', }, }

Let's display some elements of our object:

console.log(obj['a']['key1']); // shows 'a1'

You can also access elements as properties:

console.log(obj.a.key1); // shows 'a1'

You can combine both methods:

console.log(obj['a'].key1); // shows 'a1' console.log(obj.a['key1']); // shows 'a1'

Given the following object:

let obj = { key1: { key1: 1, key2: 2, key3: 3, }, key2: { key1: 4, key2: 5, key3: 6, }, key3: { key1: 7, key2: 8, key3: 9, }, }

Find the sum of the elements of this object.

Given the following object:

let obj = { 1: { 1: 'a1', 2: 'a2', 3: 'a3', }, 2: { 1: 'b1', 2: 'b2', 3: 'b3', }, 3: { 1: 'c1', 2: 'c2', 3: 'c3', }, }

Display the element 'b2' and the element 'c1'.

Given the following object:

let obj = { key1: { a: 1, b: 2, c: { d: 3, e: 4, }, f: 5, }, key2: { g: 6, h: 7, }, }

Manually - without a loop, find the sum of all elements-numbers.

enru