Skip to content
Merged
Changes from all commits
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
20 changes: 20 additions & 0 deletions 04 - Array Cardio Day 1/index-START.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,34 @@

// 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 links = [...category.querySelectorAll('a')];
const de = links
.map(link => link.textContent)
.filter(streetName => streetName.includes('de'));*/


// 7. sort Exercise
// Sort the people alphabetically by last name
const alphabeticalSort = people.sort((a, b) => {
const [aLast, aFirst] = a.split(', ');
const [bLast, bFirst] = b.split(', ');
return aLast > bLast ? 1 : -1;
});
console.log(alphabeticalSort);

// 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