Skip to content

Commit aa9c89d

Browse files
committed
Doing a little array cardio
1 parent a339c6d commit aa9c89d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,33 @@
2727

2828
// Array.prototype.filter()
2929
// 1. Filter the list of inventors for those who were born in the 1500's
30+
31+
const inventorsBornInThe1500s = inventors.filter(inventor => inventor.year >= 1500 && inventor.year < 1600);
32+
33+
console.table(inventorsBornInThe1500s);
3034

3135
// Array.prototype.map()
3236
// 2. Give us an array of the inventory first and last names
37+
const firstAndLastNames = inventors.map(inventor => `${inventor.first} ${inventor.last}`);
38+
console.table(firstAndLastNames);
3339

3440
// Array.prototype.sort()
3541
// 3. Sort the inventors by birthdate, oldest to youngest
42+
const ordered = inventors.sort(function(a, b) {
43+
// return a.
44+
});
3645

3746
// Array.prototype.reduce()
3847
// 4. How many years did all the inventors live?
48+
const years = inventors.reduce(function(inventor) {
49+
50+
});
3951

4052
// 5. Sort the inventors by years lived
4153

4254
// 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name
4355
// https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris
4456

45-
4657
// 7. sort Exercise
4758
// Sort the people alphabetically by last name
4859

0 commit comments

Comments
 (0)