22 lines
409 B
Markdown
22 lines
409 B
Markdown
importance: 5
|
|
|
|
---
|
|
|
|
# Sort objects
|
|
|
|
Write the function `getNames(users)` that gets an array of "user" objects with property `name` and returns an array of names.
|
|
|
|
For instance:
|
|
|
|
```js no-beautify
|
|
let john = { name: "John", age: 25 }
|
|
let pete = { name: "Pete", age: 30 }
|
|
let mary = { name: "Mary", age: 28 }
|
|
|
|
let arr = [ john, pete, mary ];
|
|
|
|
let names = getNames(arr);
|
|
|
|
alert( names ) // John, Pete, Mary
|
|
```
|
|
|