Skip to content

Commit 0e624eb

Browse files
author
Jonathan Alorda
committed
Done with Array Cardio Day 1.
1 parent 63f5349 commit 0e624eb

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

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

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
const flavours = ['Chocolate Chip', 'Kulfi', 'Caramel Praline', 'Chocolate', 'Burnt Caramel', 'Pistachio', 'Rose', 'Sweet Coconut', 'Lemon Cookie', 'Toffeeness', 'Toasted Almond', 'Black Raspberry Crunch', 'Chocolate Brownies', 'Pistachio Almond', 'Strawberry', 'Lavender Honey', 'Lychee', 'Peach', 'Black Walnut', 'Birthday Cake', 'Mexican Chocolate', 'Mocha Almond Fudge', 'Raspberry'];
2525

26-
const people = ['Beck, Glenn', 'Becker, Carl', 'Beckett, Samuel', 'Beddoes, Mick', 'Beecher, Henry', 'Beethoven, Ludwig', 'Begin, Menachem', 'Belloc, Hilaire', 'Bellow, Saul', 'Benchley, Robert', 'Benenson, Peter', 'Ben-Gurion, David', 'Benjamin, Walter', 'Benn, Tony', 'Bennington, Chester', 'Benson, Leana', 'Bent, Silas', 'Bentsen, Lloyd', 'Berger, Ric', 'Bergman, Ingmar', 'Berio, Luciano', 'Berle, Milton', 'Berlin, Irving', 'Berne, Eric', 'Bernhard, Sandra', 'Berra, Yogi', 'Berry, Halle', 'Berry, Wendell', 'Bethea, Erin', 'Bevan, Aneurin', 'Bevel, Ken', 'Biden, Joseph', 'Bierce, Ambrose', 'Biko, Steve', 'Billings, Josh', 'Biondo, Frank', 'Birrell, Augustine', 'Black Elk', 'Blair, Robert', 'Blair, Tony', 'Blake, William'];
26+
const people = ['Becker, Carl', 'Beckett, Samuel', 'Beddoes, Mick', 'Beecher, Henry', 'Beethoven, Ludwig', 'Begin, Menachem', 'Berger, Ric', 'Belloc, Hilaire', 'Bellow, Saul', 'Benchley, Robert', 'Benenson, Peter', 'Ben-Gurion, David', 'Benjamin, Walter', 'Benn, Tony', 'Bennington, Chester', 'Blake, William', 'Benson, Leana', 'Bent, Silas', 'Bentsen, Lloyd', 'Bergman, Ingmar', 'Berio, Luciano', 'Berle, Milton', 'Berlin, Irving', 'Berne, Eric', 'Bernhard, Sandra', 'Berra, Yogi', 'Berry, Halle', 'Berry, Wendell', 'Bethea, Erin', 'Bevan, Aneurin', 'Bevel, Ken', 'Beck, Glenn', 'Biden, Joseph', 'Bierce, Ambrose', 'Biko, Steve', 'Billings, Josh', 'Biondo, Frank', 'Birrell, Augustine', 'Black Elk', 'Blair, Robert', 'Blair, Tony'];
2727

2828
// Array.prototype.filter()
2929
// 1. Filter the list of inventors for those who were born in the 1500's
@@ -48,18 +48,44 @@
4848
return nextInventorAge - lastInventorAge;
4949
}
5050
);
51-
console.table(byOldest);
51+
console.table('by oldest: ', byOldest);
52+
5253
// 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name
5354
// https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris
55+
const category = document.querySelector('.mw-category');
56+
// change this into an array!
57+
const links = Array.from(category.querySelectorAll('a'));
58+
59+
const de = links
60+
.map(link => link.textContent)
61+
.filter(streetName => streetName.includes('de'));
5462

5563

5664
// 7. sort Exercise
5765
// Sort the people alphabetically by last name
66+
const alpha = people.sort(function(lastOne, nextOne) {
67+
const [aLast, aFirst] = lastOne.split(', ');
68+
const [bLast, bFirst] = nextOne.split(', ');
69+
70+
console.log(last, first);
71+
});
5872

5973
// 8. Reduce Exercise
6074
// Sum up the instances of each of these
6175
const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ];
6276

77+
const transportation = data.reduce(function(obj, item) {
78+
console.log('obj: ', obj);
79+
console.log('item: ', item);
80+
if(!obj[item]) {
81+
obj[item] = 0;
82+
}
83+
obj[item]++;
84+
return obj;
85+
}, {})
86+
87+
console.log(transportation);
88+
6389
</script>
6490
</body>
6591
</html>

0 commit comments

Comments
 (0)