From 740b26a07d61c10433077de19921582263f77296 Mon Sep 17 00:00:00 2001 From: Kristyn Bryan Date: Mon, 23 May 2016 15:55:47 -0400 Subject: [PATCH 1/7] Update Solutions_w02d02_morning_exercise.md --- .../Solutions_w02d02_morning_exercise.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/unit_01/w02d02/morning_exercise/Solutions_w02d02_morning_exercise.md b/unit_01/w02d02/morning_exercise/Solutions_w02d02_morning_exercise.md index 8df6b6a..c5d1748 100644 --- a/unit_01/w02d02/morning_exercise/Solutions_w02d02_morning_exercise.md +++ b/unit_01/w02d02/morning_exercise/Solutions_w02d02_morning_exercise.md @@ -1,9 +1,5 @@ # W02D02 Morning Warmup -![Cat Programmer](http://s2.quickmeme.com/img/99/9903c7c14add3fd0758b7b5b80c24d48101f296f13ce34736799a82c71f61bc2.jpg) - - - # JAVASCRIPT ITERATORS #####`.forEach`, `.map`, and `.reduce` @@ -26,7 +22,16 @@ arr.forEach(function(n) { => Prints a bunch of 9s to the console ``` +
+SOLUTION to .forEach + +```javascript +words = ["Ho", "Chi", "Minh", "City", "was", "once", "known", "as", "Prey", "Nokor"]; +words.forEach(function (e){ + console.log(e.toUpperCase()); +}); +``` ##### EXERCISE: - Log each word in `words` in upper case using `.forEach.` From 7efe896e12600153a1a7be1e68d0bc84586a053f Mon Sep 17 00:00:00 2001 From: Kristyn Bryan Date: Mon, 23 May 2016 15:56:33 -0400 Subject: [PATCH 2/7] Update Solutions_w02d02_morning_exercise.md --- .../Solutions_w02d02_morning_exercise.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/unit_01/w02d02/morning_exercise/Solutions_w02d02_morning_exercise.md b/unit_01/w02d02/morning_exercise/Solutions_w02d02_morning_exercise.md index c5d1748..5ee6837 100644 --- a/unit_01/w02d02/morning_exercise/Solutions_w02d02_morning_exercise.md +++ b/unit_01/w02d02/morning_exercise/Solutions_w02d02_morning_exercise.md @@ -22,15 +22,6 @@ arr.forEach(function(n) { => Prints a bunch of 9s to the console ``` -
-SOLUTION to .forEach - -```javascript -words = ["Ho", "Chi", "Minh", "City", "was", "once", "known", "as", "Prey", "Nokor"]; - -words.forEach(function (e){ - console.log(e.toUpperCase()); -}); ``` ##### EXERCISE: @@ -40,7 +31,15 @@ words.forEach(function (e){ words = ["Ho", "Chi", "Minh", "City", "was", "once", "known", "as", "Prey", "Nokor"]; ``` +
+SOLUTION to .forEach + +```javascript +words = ["Ho", "Chi", "Minh", "City", "was", "once", "known", "as", "Prey", "Nokor"]; +words.forEach(function (e){ + console.log(e.toUpperCase()); +}); # .map From 7ecf469b3b725e8d6e27eb20711ebeedb408f0c6 Mon Sep 17 00:00:00 2001 From: Kristyn Bryan Date: Mon, 23 May 2016 15:57:25 -0400 Subject: [PATCH 3/7] Update Solutions_w02d02_morning_exercise.md --- .../morning_exercise/Solutions_w02d02_morning_exercise.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/unit_01/w02d02/morning_exercise/Solutions_w02d02_morning_exercise.md b/unit_01/w02d02/morning_exercise/Solutions_w02d02_morning_exercise.md index 5ee6837..a4b843a 100644 --- a/unit_01/w02d02/morning_exercise/Solutions_w02d02_morning_exercise.md +++ b/unit_01/w02d02/morning_exercise/Solutions_w02d02_morning_exercise.md @@ -21,7 +21,6 @@ arr.forEach(function(n) { => Prints a bunch of 9s to the console -``` ``` ##### EXERCISE: @@ -40,7 +39,7 @@ words = ["Ho", "Chi", "Minh", "City", "was", "once", "known", "as", "Prey", "Nok words.forEach(function (e){ console.log(e.toUpperCase()); }); - +``` # .map From be7916569d4b14e828d16e1c3bd3d2de5730ff07 Mon Sep 17 00:00:00 2001 From: Kristyn Bryan Date: Mon, 23 May 2016 16:14:23 -0400 Subject: [PATCH 4/7] Update Solutions_w02d02_morning_exercise.md --- .../Solutions_w02d02_morning_exercise.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/unit_01/w02d02/morning_exercise/Solutions_w02d02_morning_exercise.md b/unit_01/w02d02/morning_exercise/Solutions_w02d02_morning_exercise.md index a4b843a..3fd0947 100644 --- a/unit_01/w02d02/morning_exercise/Solutions_w02d02_morning_exercise.md +++ b/unit_01/w02d02/morning_exercise/Solutions_w02d02_morning_exercise.md @@ -69,6 +69,17 @@ Expected result: ``` ["J", "O", "E"] ``` +SOLUTION: .map +```javascript +more_words = ["Joe", "Overreats", "Eggs"]; + + +var new_arr = more_words.map(function (i){ + return i.charAt(0); +}); + +console.log (new_arr); +``` ... From a2ac4ab156695205eac73397e1fcc4eb2f79f265 Mon Sep 17 00:00:00 2001 From: Kristyn Bryan Date: Mon, 23 May 2016 16:56:49 -0400 Subject: [PATCH 5/7] Update README.md --- unit_01/w02d02/morning_exercise/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/unit_01/w02d02/morning_exercise/README.md b/unit_01/w02d02/morning_exercise/README.md index ebfd50a..303599c 100644 --- a/unit_01/w02d02/morning_exercise/README.md +++ b/unit_01/w02d02/morning_exercise/README.md @@ -78,6 +78,8 @@ Expected result: Add together all numbers in an array: ``` +arr = [8, 8, 8, 8, 8, 8, 8, 8]; + new_value = arr.reduce(function(sum, n){ return sum += n }); @@ -91,7 +93,7 @@ new_value = arr.reduce(function(sum, n){ arr = [8, 8, 8, 8, 8, 8, 8, 8]; ``` -- Return the product of the numbers in `arr`. +- Return the *product* of the numbers in `arr`. From 7272245b62242b1cfa801cef418a921c66eb8ac6 Mon Sep 17 00:00:00 2001 From: Kristyn Bryan Date: Mon, 23 May 2016 16:58:27 -0400 Subject: [PATCH 6/7] Update Solutions_w02d02_morning_exercise.md --- .../Solutions_w02d02_morning_exercise.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/unit_01/w02d02/morning_exercise/Solutions_w02d02_morning_exercise.md b/unit_01/w02d02/morning_exercise/Solutions_w02d02_morning_exercise.md index 3fd0947..7b263b1 100644 --- a/unit_01/w02d02/morning_exercise/Solutions_w02d02_morning_exercise.md +++ b/unit_01/w02d02/morning_exercise/Solutions_w02d02_morning_exercise.md @@ -107,7 +107,16 @@ arr = [8, 8, 8, 8, 8, 8, 8, 8]; - Return the product of the numbers in `arr`. +SOLUTION .reduce +```javascript +arr = [8, 8, 8, 8, 8, 8, 8, 8]; +new_value = arr.reduce(function(product, n){ + return product *= n +}); + +console.log(new_value); +``` ... From 846805d14fa27494d900b3480bccba46c9c5c959 Mon Sep 17 00:00:00 2001 From: Kristyn Bryan Date: Mon, 23 May 2016 16:59:33 -0400 Subject: [PATCH 7/7] Update Solutions_w02d02_morning_exercise.md --- .../morning_exercise/Solutions_w02d02_morning_exercise.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unit_01/w02d02/morning_exercise/Solutions_w02d02_morning_exercise.md b/unit_01/w02d02/morning_exercise/Solutions_w02d02_morning_exercise.md index 7b263b1..f3d85e4 100644 --- a/unit_01/w02d02/morning_exercise/Solutions_w02d02_morning_exercise.md +++ b/unit_01/w02d02/morning_exercise/Solutions_w02d02_morning_exercise.md @@ -151,7 +151,7 @@ var sheepShearers = [ /////////////////////////// SOLUTION: sheepShearer - +```javascript var sheepShearers = [ { name: "Tim", @@ -180,7 +180,7 @@ var total = sheepShearers }); console.log(total); - +``` #### FINISHED EARLY?: