my data. data also has empty entries
const aadharData = [
{
firstName: "Ritam",
lastName: "Singhal",
address: {
location: "rampur",
state: "up",
},
hasDrivingLicense: false,
emails: ["[email protected]", "[email protected]", "[email protected]"],
},
{
firstName: "Siddarth",
lastName: "Singhal",
address: {
location: "chandigarh",
state: "haryana",
},
hasDrivingLicense: false,
emails: ["[email protected]"],
},
];
1. what I managed to filter out was a list of emails and fullname. with following code
let gmailList = [];
aadharData.forEach((info) => {
if (info.emails) {
let fullname = info.firstName + " " + info.lastName;
let email = info.emails;
gmailList.push({ fullname, email });
}
});
2. I want to filter only those emailID that are gmails. however, I don't know how to iterate inside the property. I tried using forEach, some, and filter inside forEach but that doesn't seem to work or at least I don't know how to use them effectively. my assignment states I can't use for loop. finally, i want results in the format as
{ fullname, gmail }
example
{ fullname: "Mayank Attri", email: ["[email protected]"] };