Skip to content

Commit f154ab2

Browse files
finished 4
1 parent bec1822 commit f154ab2

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,39 @@
6565
// 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name
6666
// https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris
6767

68-
68+
// const category = document.querySelector('.mw-category')
69+
// const links = Array.from(category.querySelectorAll('a'))
70+
// const de = links.map(links => link.textContent)
71+
// .filter(streetName => streetName.includes('de'))
6972

7073
// 7. sort Exercise
7174
// Sort the people alphabetically by last name
7275

76+
const alpha = people.sort((lastOne, nextOne) => {
77+
const [aLast, aFirst] = lastOne.split(', ')
78+
const [bLast, bFirst] = nextOne.split(', ')
79+
80+
return aLast > bLast ? 1 : -1
81+
})
82+
83+
console.log(alpha)
84+
85+
7386
// 8. Reduce Exercise
7487
// Sum up the instances of each of these
7588
const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ];
7689

90+
const transportation = data.reduce(function(obj, item) {
91+
if(!obj[item]) {
92+
obj[item] = 0
93+
}
94+
obj[item]++
95+
return obj
96+
}, {})
97+
98+
console.log(transportation)
99+
100+
77101
</script>
78102
</body>
79103
</html>

0 commit comments

Comments
 (0)