Write a function `getNames(users)` that extracts only the `name` property from each user object in the array.
Problem Statement
Write a function `getNames(users)` that extracts only the `name` property from each user object in the array.
Complexity
Time Complexity: -
Space Complexity: -
Hints
š” Hint 1:
Array.map() transforms each element of an array.
š” Hint 2:
You can destructure inside the map callback.
š” Hint 3:
return users.map(u => u.name); or users.map(({name}) => name);
ā
Solution:
```javascript
function getNames(users) {
return users.map(u => u.name);
}
```