Skip to content

Commit f5594da

Browse files
committed
completed wesbos#7, sort Exercise, sort people alphabetically by last name
1 parent b2dd1c4 commit f5594da

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

04 - Array Cardio Day 1/index-START.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,21 @@
6363

6464
// 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name
6565
// https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris
66-
66+
//skipping #6... hard one...
6767

6868
// 7. sort Exercise
6969
// Sort the people alphabetically by last name
70+
inventors.sort( (a, b) => {
71+
if (a.last < b.last) {
72+
return -1;
73+
} else if (a.last > b.last) {
74+
return 1;
75+
} else {
76+
return 0;
77+
}
78+
} );
79+
console.log('sorting people alphabetically by last name');
80+
console.table(inventors);
7081

7182
// 8. Reduce Exercise
7283
// Sum up the instances of each of these

0 commit comments

Comments
 (0)