Skip to content

Commit 0d807ac

Browse files
committed
Finish day 4
1 parent f2ba071 commit 0d807ac

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,19 @@
7979
const [bLast, bFirst] = nextOne.split(', ');
8080
return aLast > bLast ? 1 : -1
8181
});
82-
console.log("alpha")
8382
console.log(alpha);
8483

8584

8685
// 8. Reduce Exercise
8786
// Sum up the instances of each of these
8887
const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ];
8988

89+
const transportation = data.reduce(function(obj, item) {
90+
if (!obj[item]) { obj[item] = 0; }
91+
obj[item]++;
92+
return obj;
93+
}, {});
94+
console.log(transportation);
9095
</script>
9196
</body>
9297
</html>

0 commit comments

Comments
 (0)