We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e318e60 commit 7702aa5Copy full SHA for 7702aa5
1 file changed
04 - Array Cardio Day 1/index-START.html
@@ -67,17 +67,19 @@
67
68
// 7. sort Exercise
69
// Sort the people alphabetically by last name
70
- inventors.sort( (a, b) => {
71
- if (a.last < b.last) {
+ people.sort( (a, b) => {
+ let arrA = a.split(', ');
72
+ let arrB = b.split(', ');
73
+ if (arrA[0] < arrB[0]) {
74
return -1;
- } else if (a.last > b.last) {
75
+ } else if (arrA[0] > arrB[0]) {
76
return 1;
77
} else {
78
return 0;
79
}
80
} );
81
console.log('sorting people alphabetically by last name');
- console.table(inventors);
82
+ console.table(people);
83
84
// 8. Reduce Exercise
85
// Sum up the instances of each of these
0 commit comments