Skip to content

Commit 7702aa5

Browse files
committed
redid wesbos#7 after viewing video. last commit for wesbos#7 was incorrect
1 parent e318e60 commit 7702aa5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,19 @@
6767

6868
// 7. sort Exercise
6969
// Sort the people alphabetically by last name
70-
inventors.sort( (a, b) => {
71-
if (a.last < b.last) {
70+
people.sort( (a, b) => {
71+
let arrA = a.split(', ');
72+
let arrB = b.split(', ');
73+
if (arrA[0] < arrB[0]) {
7274
return -1;
73-
} else if (a.last > b.last) {
75+
} else if (arrA[0] > arrB[0]) {
7476
return 1;
7577
} else {
7678
return 0;
7779
}
7880
} );
7981
console.log('sorting people alphabetically by last name');
80-
console.table(inventors);
82+
console.table(people);
8183

8284
// 8. Reduce Exercise
8385
// Sum up the instances of each of these

0 commit comments

Comments
 (0)