Skip to content

Commit 7d419d9

Browse files
committed
END OF CARDIO ARRAY wesbos#1
1 parent 4681446 commit 7d419d9

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

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

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

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

7075
// 7. sort Exercise
7176
// Sort the people alphabetically by last name
72-
77+
const alphabetically = people.sort(function(lastOne, nextOne){
78+
const [aLast, aFirst] = lastOne.split(', ');
79+
const [bLast, bFirst] = nextOne.split(', ');
80+
return aLast > bLast ? 1 : -1;
81+
});
82+
console.log(alphabetically);
7383
// 8. Reduce Exercise
7484
// Sum up the instances of each of these
7585
const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ];
7686

87+
const transportation = data.reduce(function(obj, item){
88+
if (!obj[item]){
89+
obj[item] = 0;
90+
}
91+
obj[item] ++;
92+
return obj;
93+
}, {});
94+
95+
console.log(transportation);
96+
7797
</script>
7898
</body>
7999
</html>

0 commit comments

Comments
 (0)