Skip to content

Commit 1e1a3a0

Browse files
committed
Exersice 4 wesbos#8
1 parent f487088 commit 1e1a3a0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,22 @@
8989
// Sort the people alphabetically by last name
9090

9191
const alpha = people.sort(function(lastOne, nextOne) {
92-
const parts = lastOne.split(', ');
93-
console.log(lastOne);
94-
})
92+
const [alast, afirst] = lastOne.split(', ');
93+
const [blast, bfirst] = nextOne.split(', ');
94+
return blast > blast ? 1 : -1;
95+
});
96+
console.log(alpha);
9597

9698
// 8. Reduce Exercise
9799
// Sum up the instances of each of these
98100
const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ];
101+
const transportation = data.reduce(function(obj, item) {
102+
obj[item]++;
103+
return obj;
104+
}, {});
99105

106+
console.log(transportation);
107+
100108
</script>
101109
</body>
102110
</html>

0 commit comments

Comments
 (0)