Day 3: Sort Array of Objects
Submissions will no longer be placed on the leaderboard. You may still attempt this problem for practice.
Objective
Practice sorting an array.
Resources
Here are some quick tutorials on sort:
JavaScript Array sort()
Sorting an Array of Objects by Property
Task
An array of objects, , is provided for you in the editor. Complete the code below so that it sorts 's elements alphabetically by book name and then prints the sorted object.
Note: There is no input to be read, and there are no sample test cases.
xxxxxxxxxx
27
1
2
3
function sortLibrary() {
4
// var library is defined, use it in your code
5
// use console.log(library) to output the sorted library data
6
}
7
8
// tail starts here
9
var library = [
10
{
11
author: 'Bill Gates',
12
title: 'The Road Ahead',
13
libraryID: 1254
14
},
15
{
16
author: 'Steve Jobs',
17
title: 'Walter Isaacson',
18
libraryID: 4264
19
},
20
{
21
author: 'Suzanne Collins',
22
title: 'Mockingjay: The Final Book of The Hunger Games',
23
libraryID: 3245
24
}
25
];
26
27
sortLibrary();