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 risposta
Hi Puch,Below is example for your understanindg you can use for your code:-
if you need any assistanse, Please let me know!!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];
}
}
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh