Skip to content

Commit 60f619d

Browse files
committed
Add solution for exercise 4 wesbos#8
1 parent 1e1a3a0 commit 60f619d

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,15 @@
9999
// Sum up the instances of each of these
100100
const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ];
101101
const transportation = data.reduce(function(obj, item) {
102+
if(!obj[item]) {
103+
obj[item] = 0;
104+
}
102105
obj[item]++;
103106
return obj;
104107
}, {});
105108

106109
console.log(transportation);
107-
110+
108111
</script>
109112
</body>
110113
</html>

0 commit comments

Comments
 (0)