Skip to content

Commit 907dd8e

Browse files
committed
04 - Array Cardio Day 1: Answer wesbos#8
1 parent caa07a0 commit 907dd8e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,14 @@
8888
// 8. Reduce Exercise
8989
// Sum up the instances of each of these
9090
const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck'];
91-
91+
const transportation = data.reduce((acc, curr) => {
92+
if (!(curr in acc)) {
93+
acc[curr] = 0
94+
}
95+
acc[curr]++
96+
return acc
97+
}, {})
98+
console.log(transportation);
9299
</script>
93100
</body>
94101

0 commit comments

Comments
 (0)