Create a function named "justEmails". The function should accept a parameter for JSON data named "data". The function should loop through the JSON user data with forEach(). Using the push method, add each user
1) Create a function named "justEmails". The function should accept a parameter for JSON data named "data". The function should loop through the JSON user data with forEach(). Using the push method, add each user email to a new array
// Return the new array of emails.
// Test your function with this
// JSON data:
const jsonData = [
{
id: 1,
name: "Leanne Graham",
username: "Bret",
email: "Sincere@april.biz"
},
{
id: 2,
name: "Ervin Howell",
username: "Antonette",
email: "Shanna@melissa.tv"
},
{
id: 3,
name: "Clementine Bauch",
username: "Samantha",
email: "Nathan@yesenia.net"
}
];
//////////////////
HINT: The Higher Order Functions filter(), map(), and reduce() have inner functions that use a return statement. By putting HOFs inside of a function you create, you will also need to return the result of the HOFs.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images