|
1 | 1 | <!DOCTYPE html>
|
2 | 2 | <html lang="en">
|
3 |
| -<head> |
4 |
| - <meta charset="UTF-8"> |
5 |
| - <title>Array Cardio 💪</title> |
6 |
| - <link rel="icon" href="https://fav.farm/🔥" /> |
7 |
| -</head> |
8 |
| -<body> |
9 |
| - <p><em>Psst: have a look at the JavaScript Console</em> 💁</p> |
10 |
| - <script> |
11 |
| - // Get your shorts on - this is an array workout! |
12 |
| - // ## Array Cardio Day 1 |
| 3 | + <head> |
| 4 | + <meta charset="UTF-8" /> |
| 5 | + <title>Array Cardio 💪</title> |
| 6 | + <link rel="icon" href="https://fav.farm/🔥" /> |
| 7 | + </head> |
| 8 | + <body> |
| 9 | + <p><em>Psst: have a look at the JavaScript Console</em> 💁</p> |
| 10 | + <script> |
| 11 | + // Get your shorts on - this is an array workout! |
| 12 | + // ## Array Cardio Day 1 |
13 | 13 |
|
14 |
| - // Some data we can work with |
| 14 | + // Some data we can work with |
15 | 15 |
|
16 |
| - const inventors = [ |
17 |
| - { first: 'Albert', last: 'Einstein', year: 1879, passed: 1955 }, |
18 |
| - { first: 'Isaac', last: 'Newton', year: 1643, passed: 1727 }, |
19 |
| - { first: 'Galileo', last: 'Galilei', year: 1564, passed: 1642 }, |
20 |
| - { first: 'Marie', last: 'Curie', year: 1867, passed: 1934 }, |
21 |
| - { first: 'Johannes', last: 'Kepler', year: 1571, passed: 1630 }, |
22 |
| - { first: 'Nicolaus', last: 'Copernicus', year: 1473, passed: 1543 }, |
23 |
| - { first: 'Max', last: 'Planck', year: 1858, passed: 1947 }, |
24 |
| - { first: 'Katherine', last: 'Blodgett', year: 1898, passed: 1979 }, |
25 |
| - { first: 'Ada', last: 'Lovelace', year: 1815, passed: 1852 }, |
26 |
| - { first: 'Sarah E.', last: 'Goode', year: 1855, passed: 1905 }, |
27 |
| - { first: 'Lise', last: 'Meitner', year: 1878, passed: 1968 }, |
28 |
| - { first: 'Hanna', last: 'Hammarström', year: 1829, passed: 1909 } |
29 |
| - ]; |
| 16 | + const inventors = [ |
| 17 | + { first: "Albert", last: "Einstein", year: 1879, passed: 1955 }, |
| 18 | + { first: "Isaac", last: "Newton", year: 1643, passed: 1727 }, |
| 19 | + { first: "Galileo", last: "Galilei", year: 1564, passed: 1642 }, |
| 20 | + { first: "Marie", last: "Curie", year: 1867, passed: 1934 }, |
| 21 | + { first: "Johannes", last: "Kepler", year: 1571, passed: 1630 }, |
| 22 | + { first: "Nicolaus", last: "Copernicus", year: 1473, passed: 1543 }, |
| 23 | + { first: "Max", last: "Planck", year: 1858, passed: 1947 }, |
| 24 | + { first: "Katherine", last: "Blodgett", year: 1898, passed: 1979 }, |
| 25 | + { first: "Ada", last: "Lovelace", year: 1815, passed: 1852 }, |
| 26 | + { first: "Sarah E.", last: "Goode", year: 1855, passed: 1905 }, |
| 27 | + { first: "Lise", last: "Meitner", year: 1878, passed: 1968 }, |
| 28 | + { first: "Hanna", last: "Hammarström", year: 1829, passed: 1909 }, |
| 29 | + ]; |
30 | 30 |
|
31 |
| - const people = [ |
32 |
| - 'Bernhard, Sandra', 'Bethea, Erin', 'Becker, Carl', 'Bentsen, Lloyd', 'Beckett, Samuel', 'Blake, William', 'Berger, Ric', 'Beddoes, Mick', 'Beethoven, Ludwig', |
33 |
| - 'Belloc, Hilaire', 'Begin, Menachem', 'Bellow, Saul', 'Benchley, Robert', 'Blair, Robert', 'Benenson, Peter', 'Benjamin, Walter', 'Berlin, Irving', |
34 |
| - 'Benn, Tony', 'Benson, Leana', 'Bent, Silas', 'Berle, Milton', 'Berry, Halle', 'Biko, Steve', 'Beck, Glenn', 'Bergman, Ingmar', 'Black, Elk', 'Berio, Luciano', |
35 |
| - 'Berne, Eric', 'Berra, Yogi', 'Berry, Wendell', 'Bevan, Aneurin', 'Ben-Gurion, David', 'Bevel, Ken', 'Biden, Joseph', 'Bennington, Chester', 'Bierce, Ambrose', |
36 |
| - 'Billings, Josh', 'Birrell, Augustine', 'Blair, Tony', 'Beecher, Henry', 'Biondo, Frank' |
37 |
| - ]; |
38 |
| - |
39 |
| - // Array.prototype.filter() |
40 |
| - // 1. Filter the list of inventors for those who were born in the 1500's |
| 31 | + const people = [ |
| 32 | + "Bernhard, Sandra", |
| 33 | + "Bethea, Erin", |
| 34 | + "Becker, Carl", |
| 35 | + "Bentsen, Lloyd", |
| 36 | + "Beckett, Samuel", |
| 37 | + "Blake, William", |
| 38 | + "Berger, Ric", |
| 39 | + "Beddoes, Mick", |
| 40 | + "Beethoven, Ludwig", |
| 41 | + "Belloc, Hilaire", |
| 42 | + "Begin, Menachem", |
| 43 | + "Bellow, Saul", |
| 44 | + "Benchley, Robert", |
| 45 | + "Blair, Robert", |
| 46 | + "Benenson, Peter", |
| 47 | + "Benjamin, Walter", |
| 48 | + "Berlin, Irving", |
| 49 | + "Benn, Tony", |
| 50 | + "Benson, Leana", |
| 51 | + "Bent, Silas", |
| 52 | + "Berle, Milton", |
| 53 | + "Berry, Halle", |
| 54 | + "Biko, Steve", |
| 55 | + "Beck, Glenn", |
| 56 | + "Bergman, Ingmar", |
| 57 | + "Black, Elk", |
| 58 | + "Berio, Luciano", |
| 59 | + "Berne, Eric", |
| 60 | + "Berra, Yogi", |
| 61 | + "Berry, Wendell", |
| 62 | + "Bevan, Aneurin", |
| 63 | + "Ben-Gurion, David", |
| 64 | + "Bevel, Ken", |
| 65 | + "Biden, Joseph", |
| 66 | + "Bennington, Chester", |
| 67 | + "Bierce, Ambrose", |
| 68 | + "Billings, Josh", |
| 69 | + "Birrell, Augustine", |
| 70 | + "Blair, Tony", |
| 71 | + "Beecher, Henry", |
| 72 | + "Biondo, Frank", |
| 73 | + ]; |
41 | 74 |
|
42 |
| - // Array.prototype.map() |
43 |
| - // 2. Give us an array of the inventors first and last names |
| 75 | + // Array.prototype.filter() |
| 76 | + // 1. Filter the list of inventors for those who were born in the 1500's |
| 77 | + const filteredObj = inventors.filter( |
| 78 | + (inventor) => inventor.year >= 1500 && inventor.year <= 1600 |
| 79 | + ); |
| 80 | + console.table(filteredObj); |
44 | 81 |
|
45 |
| - // Array.prototype.sort() |
46 |
| - // 3. Sort the inventors by birthdate, oldest to youngest |
| 82 | + // Array.prototype.map() |
| 83 | + // 2. Give us an array of the inventors first and last names |
47 | 84 |
|
48 |
| - // Array.prototype.reduce() |
49 |
| - // 4. How many years did all the inventors live all together? |
| 85 | + // Array.prototype.sort() |
| 86 | + // 3. Sort the inventors by birthdate, oldest to youngest |
50 | 87 |
|
51 |
| - // 5. Sort the inventors by years lived |
| 88 | + // Array.prototype.reduce() |
| 89 | + // 4. How many years did all the inventors live all together? |
52 | 90 |
|
53 |
| - // 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name |
54 |
| - // https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris |
| 91 | + // 5. Sort the inventors by years lived |
55 | 92 |
|
| 93 | + // 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name |
| 94 | + // https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris |
56 | 95 |
|
57 |
| - // 7. sort Exercise |
58 |
| - // Sort the people alphabetically by last name |
| 96 | + // 7. sort Exercise |
| 97 | + // Sort the people alphabetically by last name |
59 | 98 |
|
60 |
| - // 8. Reduce Exercise |
61 |
| - // Sum up the instances of each of these |
62 |
| - const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ]; |
63 |
| - |
64 |
| - </script> |
65 |
| -</body> |
| 99 | + // 8. Reduce Exercise |
| 100 | + // Sum up the instances of each of these |
| 101 | + const data = [ |
| 102 | + "car", |
| 103 | + "car", |
| 104 | + "truck", |
| 105 | + "truck", |
| 106 | + "bike", |
| 107 | + "walk", |
| 108 | + "car", |
| 109 | + "van", |
| 110 | + "bike", |
| 111 | + "walk", |
| 112 | + "car", |
| 113 | + "van", |
| 114 | + "car", |
| 115 | + "truck", |
| 116 | + ]; |
| 117 | + </script> |
| 118 | + </body> |
66 | 119 | </html>
|
0 commit comments