Skip to content

Commit 6ff4244

Browse files
committed
solved wesbos#8 with assistance
1 parent 1af1725 commit 6ff4244

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,23 @@
9292
return lastA > lastB ? 1: -1;
9393

9494
});
95-
console.table(alphabetical);
95+
console.log(alphabetical);
9696

9797

9898
// 8. Reduce Exercise
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

102+
const instanceSum = data.reduce((obj, item) => {
103+
if(!obj[item]){
104+
obj[item] = 0;
105+
}
106+
obj[item]++;
107+
return obj;
108+
}, {});
109+
110+
console.log(instanceSum);
111+
102112
</script>
103113
</body>
104114
</html>

0 commit comments

Comments
 (0)