JavaScript is still new to me and I'm struggling with mapping an array. I'm not sure how to return an array with objects.
Here is the original array:
array1 = [{firstName: "Harry"},
{lastName: "Potter"}];
After using array1.map
, it currently shows:
array1 = ["Potter"];
My goal is to have array1
transformed like this after mapping the lastName
:
array1 = [{lastName: "Potter"}];