From 1e248f235ccd2d4e638363d979d7c94736f0686d Mon Sep 17 00:00:00 2001 From: Dustin Leer Date: Fri, 12 Oct 2018 19:31:32 -0400 Subject: [PATCH 1/2] FInished exercise 7 on Exercise 4 on completed --- 04 - Array Cardio Day 1/scripts.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/04 - Array Cardio Day 1/scripts.js b/04 - Array Cardio Day 1/scripts.js index cb2cd16a1f..2cdaf29ea3 100644 --- a/04 - Array Cardio Day 1/scripts.js +++ b/04 - Array Cardio Day 1/scripts.js @@ -114,10 +114,24 @@ const de = links .filter(streetName => streetName.includes('de')); */ - - // 7. sort Exercise // Sort the people alphabetically by last name +// const abc = people.sort(function(lastOne, nextOne) { +// const [aLast, aFirst] = lastOne.split(', '); +// const [bLast, bFirst] = nextOne.split(', '); +// // console.log(last, first); +// return aLast > bLast ? -1 : 1; +// }); +/******************************************************** + * ️️️☝️ Turns Proper Function into an Arrow Function ☝️ +********************************************************/ +const abc = people.sort((lastOne, nextOne) => { + const [aLast, aFirst] = lastOne.split(', '); + const [bLast, bFirst] = nextOne.split(', '); + // console.log(last, first); + return aLast > bLast ? -1 : 1; +}); +console.log(abc); // 8. Reduce Exercise // Sum up the instances of each of these From f2b15570e6ae8d9ccdfcafd03ec8b73d31b26b9c Mon Sep 17 00:00:00 2001 From: Dustin Leer Date: Fri, 12 Oct 2018 19:34:01 -0400 Subject: [PATCH 2/2] Adds old spacing --- 04 - Array Cardio Day 1/scripts.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/04 - Array Cardio Day 1/scripts.js b/04 - Array Cardio Day 1/scripts.js index 2cdaf29ea3..5ec7f72e2a 100644 --- a/04 - Array Cardio Day 1/scripts.js +++ b/04 - Array Cardio Day 1/scripts.js @@ -114,6 +114,7 @@ const de = links .filter(streetName => streetName.includes('de')); */ + // 7. sort Exercise // Sort the people alphabetically by last name // const abc = people.sort(function(lastOne, nextOne) { @@ -133,6 +134,7 @@ const abc = people.sort((lastOne, nextOne) => { }); console.log(abc); + // 8. Reduce Exercise // Sum up the instances of each of these const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck']; \ No newline at end of file