Explorer
Node.js

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); } ```

Array.map with Object Transformation

Easy
Write a function `getNames(users)` that extracts only the `name` property from each user object in the array.
Editor
Loading Editor...
Evaluate code
Output:Click "Run" above to execute and verify your code here.
["Alice","Bob","Charlie"]