Hi all, thanks for taking the time to look at my question
I’m having a bit of trouble understanding this function in the example, so i understand that the map function will iterate over users to extract the results i want.
But what i dont understand is (user => user.name), why dont we have just name? How would i read the contents inside the brackets (user => user.name),
Just to add to these good responses… the user variable is defined by the function. It could be any vaiable name you like. User is referencing the current elemant of the array and passing it to the function
This code generates an array of objects called users, each of which has two properties: a name and an age.
Finally, a new array called names is created by using the map() method to extract only the name field from each object in the users array. The callback function that is passed as a parameter to the map() method is called once for each user in the users array.
In this instance, the callback function extracts and returns the name property from each object in the users array using an arrow function.