I have this array of objects:
let authors = [
{ firstName: "Beatrix", lastName: "Potter" },
{ firstName: "Ann", lastName: "Martin" },
];
I want to unify the details after mapping the array items with map(), then reduce the objects to a single string with reduce() so the output would be "Beatrix Potter", "Ann Martin".
I have tried the following code but failed:
fullAuthorNames = authors.map( (e)=>
authors.reduce( (firstName, lastName)=> firstName + lastName );
);
This is the relevant output:
["[object Object][object Object][object Object][object Object][object Object]","[object Object][object Object][object Object][object Object][object Object]"
What did I do wrong here? Maybe I didn't target the objects inside the array right?