397 B
397 B
importance: 5
Sort objects
Write the function sortByName(users)
that gets an array of objects with property name
and sorts it.
For instance:
let john = { name: "John", age: 25 }
let pete = { name: "Pete", age: 30 }
let mary = { name: "Mary", age: 28 }
let arr = [ john, pete, mary ];
lsortByName(arr);
// now: [john, mary, pete]
alert(arr[1].name) // Mary