Skip to main content
Hello All,

I created a LWC and I need to get a field value but its inside a nested array.  How would I get the Name value in the below example?

[{"expanded":false,"items":[{"detail":{"Id":"asasasasasasa","Name":"CI-000358"

 
1 resposta
  1. 17 de mar. de 2022, 07:01
    Hi  Puch,

    Below is example for your understanindg you can use for your code:-

     

    const myObj = {

      name: "John",

      age: 30,

      cars: [

        {name:"Ford", models:["Fiesta", "Focus", "Mustang"]},

        {name:"BMW", models:["320", "X3", "X5"]},

        {name:"Fiat", models:["500", "Panda"]}

      ]

    }

    /////////////////////////////

     for (let i in myObj.cars) {

      x += "<h1>" + myObj.cars[i].name + "</h1>";

      for (let j in myObj.cars[i].models) {

        x += myObj.cars[i].models[j];

      }

    }

    if you need any assistanse, Please let me know!!

    Kindly mark my solution as the best answer if it helps you.

    Thanks

    Mukesh 
0/9000