0

How to get to level4 node and read its value

Code sample on TS playground

const sectors = {
  "level1": [{
    "Electricity": [{
      "level2": [{
        "Electricity, gas & steam production & supply": [{
          "level3": [{
            "Electric power generation, transmission and distribution": [{
              "level4": [
                "Electric power generation, transmission and distribution"
              ]
            }],
            "Manufacture of gas; distribution of gaseous fuels through mains": [{
              "level4": [
                "Manufacture of gas; distribution of gaseous fuels through mains"
              ]
            }],
            "Steam and air conditioning supply": [{
              "level4": [
                "Steam and air conditioning supply"
              ]
            }]
          }]
        }]
      }]
    }],
    "Manufacturing": [{
      "level2": [{
        "Manufacture of basic metals": [{
          "level3": [{
            "Casting of metals": [{
              "level4": [
                "Casting of iron and steel",
                "Casting of non-ferrous metals"
              ]
            }],
            "Manufacture of basic iron and steel": [{
              "level4": [
                "Manufacture of basic iron and steel"
              ]
            }],
            "Manufacture of basic precious and other non-ferrous metals": [{
              "level4": [
                "Manufacture of basic precious and other non-ferrous metals"
              ]
            }]
          }]
        }]
      }]
    }]
  }]
}

console.clear();
//console.log(Object.keys(sectors.level1));

//How to get to level4 node and read its value
console.log(sectors.level1);
mplungjan
  • 155,085
  • 27
  • 166
  • 222
Jalle
  • 1,488
  • 5
  • 20
  • 39

0 Answers0