From 4fca94be34c5bddc2ea559f31dafb15e41a3a1b0 Mon Sep 17 00:00:00 2001 From: Kristyn Bryan Date: Tue, 24 May 2016 14:17:04 -0400 Subject: [PATCH] morning work solutions --- unit_01/w02d02/morning_exercise/solutions.js | 52 ++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 unit_01/w02d02/morning_exercise/solutions.js diff --git a/unit_01/w02d02/morning_exercise/solutions.js b/unit_01/w02d02/morning_exercise/solutions.js new file mode 100644 index 0000000..cde6150 --- /dev/null +++ b/unit_01/w02d02/morning_exercise/solutions.js @@ -0,0 +1,52 @@ +// words = ["Ho", "Chi", "Minh", "City", "was", "once", "known", "as", "Prey", "Nokor"]; +// +// words.forEach(function (e){ +// console.log(e.toUpperCase()); +// }); + + +///////////////////// + + +// more_words = ["Joe", "Overreats", "Eggs"]; +// +// +// var new_arr = more_words.map(function (i){ +// return i.charAt(0); +// }); +// +// console.log (new_arr); + +/////////////////// + +// arr = [8, 8, 8, 8, 8, 8, 8, 8]; +// +// new_value = arr.reduce(function(product, n){ +// return product *= n +// }); +// +// console.log(new_value); + +///////////////////// + +var sheepShearers = [ + { + name: "Tim", + age: 20, + sheepCount: 18 + }, + { + name: "C3PO", + age: 200, + sheepCount: 320 + }, + { + name: "Cousin It", + age: Infinity, + sheepCount: 2900 + } +]; + +var total = sheepShearers.map(function(e){return e.sheepCount})).reduce(function(sum, num) {resturn sum += num;}); + +console.log (total);