Skip to content

Commit 55f8c97

Browse files
half-way through challenge wesbos#4
1 parent 07afda6 commit 55f8c97

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,46 @@
3838
// Array.prototype.filter()
3939
// 1. Filter the list of inventors for those who were born in the 1500's
4040

41+
function checkBorn() {
42+
console.log(inventors.filter(inventors => inventors.year >= 1500 && inventors.year <= 1599));
43+
}
44+
checkBorn();
45+
4146
// Array.prototype.map()
4247
// 2. Give us an array of the inventors first and last names
48+
49+
// using functions to map over inventors
50+
function getFullName(person) {
51+
const fullName = [person.first, person.last].join(" ");
52+
return fullName;
53+
}
54+
55+
function logName() {
56+
console.log(inventors.map(getFullName))
57+
}
58+
59+
logName();
60+
61+
// other way of mapping over inventors
62+
const inventorNames = inventors.map(inventor => `${inventor.first} ${inventor.last}`);
63+
console.log(inventorNames);
4364

4465
// Array.prototype.sort()
4566
// 3. Sort the inventors by birthdate, oldest to youngest
4667

68+
function sortInventors() {
69+
console.log(inventors.sort(function(a, b) {return b.year-a.year}));
70+
}
71+
sortInventors();
72+
73+
const inventorBirthDate = inventors.sort((a, b) => a.year - b.year);
74+
console.log(inventorBirthDate);
75+
4776
// Array.prototype.reduce()
4877
// 4. How many years did all the inventors live all together?
4978

79+
80+
5081
// 5. Sort the inventors by years lived
5182

5283
// 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name

0 commit comments

Comments
 (0)