Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c398cb6

Browse files
committed
Update with solution to wesbos#8
1 parent 8c42f19 commit c398cb6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,16 @@
8787
// Sum up the instances of each of these
8888
const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ];
8989

90+
const transportation = data.reduce(function(obj, item) {
91+
if (!obj[item]) {
92+
obj[item] = 0;
93+
}
94+
obj[item]++;
95+
return obj;
96+
}, {});
97+
98+
console.log(transportation);
99+
90100
</script>
91101
</body>
92102
</html>

0 commit comments

Comments
 (0)