I need to read the ids from nested loop using Javascript.
Input:
let data = [3,[{
"Id": 30,
"Name":"John"
},{
"Id": 33,
"Name":"Jill"
},{
"Id": 34,
"Name":"Jerena"
}]]
Output:
[30,33,34]
I’m stuck with this from sometime. Using maps
let Ids = [data[0][1]].map(a => a.Id);
>Solution :
Try this
let data = [3,[{
"Id": 30,
"Name":"John"
},{
"Id": 33,
"Name":"Jill"
},{
"Id": 34,
"Name":"Jerena"
}]]
console.log(data[1].map(r => r.Id))