We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d933bfc commit c22dd28Copy full SHA for c22dd28
04 - Array Cardio Day 1/index-START.html
@@ -157,7 +157,7 @@
157
const [bLast, bFirst] = b.split(", ");
158
return aFirst > bFirst ? 1 : -1;
159
});
160
- console.log(alphaSort);
+ // console.log(alphaSort);
161
162
// 8. Reduce Exercise
163
// Sum up the instances of each of these
@@ -177,6 +177,15 @@
177
"car",
178
"truck",
179
];
180
+
181
+ const sums = data.reduce((newObject, item) => {
182
+ if (!newObject[item]) {
183
+ newObject[item] = 0;
184
+ }
185
+ newObject[item]++;
186
+ return newObject;
187
+ }, {});
188
+ console.log(sums);
189
</script>
190
</body>
191
</html>
0 commit comments