javaScript ES6.map()
返回期望包括位置和城市基于哪个activeMember: true
memberDetail
const data = [
{
id: 131131,
title: "Completed members",
memberDetail: {
"0": {
activeMember: false,
memberDetails: {
location: "Mumbai",
Country: "India"
}
},
"1": {
activeMember: true,
memberDetails: {
location: "London",
Country: "England"
}
},
"2": {
activeMember: false,
memberDetails: {
location: "Colombo",
Country: "Sri Lanka"
}
}
}
},
{
id: 130500,
title: "Acting members",
memberDetail: {
"0": {
activeMember: false,
memberDetails: {
location: "Paris",
Country: "France"
}
},
"1": {
activeMember: false,
memberDetails: {
location: "Katmandu",
Country: "Nepal"
}
},
"2": {
activeMember: true,
memberDetails: {
location: "Dublin",
Country: "Ireland"
}
}
}
},
{
id: 131096,
title: "Pending members",
memberDetail: {
"0": {
activeMember: true,
memberDetails: {
location: "Perth",
Country: "Australia"
}
},
"1": {
activeMember: false,
memberDetails: {
location: "Berlin",
Country: "Germany"
}
}
}
}
];
const resultValue = data.map(detail => {
var obj = {
"id": detail.id,
"title": detail.title,
};
return obj
});
console.log(resultValue);