File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 38
38
// Array.prototype.filter()
39
39
// 1. Filter the list of inventors for those who were born in the 1500's
40
40
41
+ function checkBorn ( ) {
42
+ console . log ( inventors . filter ( inventors => inventors . year >= 1500 && inventors . year <= 1599 ) ) ;
43
+ }
44
+ checkBorn ( ) ;
45
+
41
46
// Array.prototype.map()
42
47
// 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 ) ;
43
64
44
65
// Array.prototype.sort()
45
66
// 3. Sort the inventors by birthdate, oldest to youngest
46
67
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
+
47
76
// Array.prototype.reduce()
48
77
// 4. How many years did all the inventors live all together?
49
78
79
+
80
+
50
81
// 5. Sort the inventors by years lived
51
82
52
83
// 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name
You can’t perform that action at this time.
0 commit comments