Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
added reduce function
  • Loading branch information
RELIAS\wcoleman committed Oct 11, 2017
commit 30cc415e249a23a2522d4b193e408bb0359a407e
11 changes: 10 additions & 1 deletion 04 - Array Cardio Day 1/index-START.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

// 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name
// https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris
/* const category = document.querySelector('.mw-category');
/*const category = document.querySelector('.mw-category');
const links = [...category.querySelectorAll('a')];
const de = links
.map(link => link.textContent)
Expand All @@ -82,6 +82,15 @@
// 8. Reduce Exercise
// Sum up the instances of each of these
const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ];
const sum = data.reduce(function(obj, item) {
if(!obj[item]){
obj[item] = 0;
}
obj[item]++;
return obj;
}, {});

console.log(sum);

</script>
</body>
Expand Down