Visitar URL original
Added Linebreaks for readability · wesbos/JavaScript30@96be817 · GitHub
Skip to content

Commit 96be817

Browse files
author
laryl.li
committed
Added Linebreaks for readability
1 parent 630ff54 commit 96be817

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,42 +31,49 @@
3131

3232
// Array.prototype.filter()
3333
// 1. Filter the list of inventors for those who were born in the 1500's
34-
3534
const born = inventors.filter(x => x.year >=1500 && x.year < 1600);
3635
console.log(born);
3736

3837
// Array.prototype.map()
3938
// 2. Give us an array of the inventors first and last names
4039
const finalnamestring = inventors.map(firstandlastname);
40+
4141
function firstandlastname (x){
4242
const space = ' '
4343
const namestring = x.first + space + x.last;
4444
return namestring;
4545
//console.log(namestring);
4646
}
47+
4748
console.log(finalnamestring);
4849

4950
// Array.prototype.sort()
5051
// 3. Sort the inventors by birthdate, oldest to youngest
5152
const sort = inventors.sort(oldesttoyoungest);
53+
5254
function oldesttoyoungest(a,b){
5355
return a.year-b.year;
5456
}
57+
5558
console.log(sort);
5659

5760
// Array.prototype.reduce()
5861
// 4. How many years did all the inventors live all together?
5962
const year = inventors.reduce(livetogether, 0);
63+
6064
function livetogether(totalyears, x){
6165
return totalyears+ (x.passed - x.year);
6266
}
67+
6368
console.log(year);
6469

6570
// 5. Sort the inventors by years lived
6671
const sortedyearslived = inventors.sort(yearslived);
72+
6773
function yearslived(a,b){
6874
return ((b.passed-b.year)-(a.passed-a.year));
6975
}
76+
7077
console.log(sortedyearslived);
7178

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

0 commit comments

Comments
 (0)