# Iterating over multidimensional objects in JavaScript

Let the following two-dimensional object be given:

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

Let's display all its elements on the screen. To do this, we need to run two nested loops `for-in`:

`for (let key in obj) { let subObj = obj[key]; for (let subKey in subObj) { console.log(subObj[subKey]); } }`

Given the following object:

`let obj = { 1: { 1: 11, 2: 12, 3: 13, }, 2: { 1: 21, 2: 22, 3: 23, }, 3: { 1: 24, 2: 25, 3: 26, }, }`

Using loops, find the sum of this object elements.

Given the following object:

`let obj = { 1: { 1: { 1: 111, 2: 112, 3: 113, }, 2: { 1: 121, 2: 122, 3: 123, }, }, 2: { 1: { 1: 211, 2: 212, 3: 213, }, 2: { 1: 221, 2: 222, 3: 223, }, }, 3: { 1: { 1: 311, 2: 312, 3: 313, }, 2: { 1: 321, 2: 322, 3: 323, }, }, }`

Using loops, find the sum of this object elements.

← →
↑
en ru