From 4dd07b6d48b22ac5d079e8d80c1c9910e9cec6fb Mon Sep 17 00:00:00 2001
From: JT Coates <wyosred@yahoo.com>
Date: Fri, 25 Mar 2022 14:20:09 -0600
Subject: [PATCH 1/2] half way done

---
 index.js | 85 +++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 51 insertions(+), 34 deletions(-)

diff --git a/index.js b/index.js
index e37f41ec7..21b4330c4 100644
--- a/index.js
+++ b/index.js
@@ -17,7 +17,7 @@ function myFunction() {
 
 //🚀🚀🚀 ⬇️ 📝 Explanation ⬇️ 📝 🚀🚀🚀: 
 
-
+"becuase you have created the nestedFunction within the scope of my Function"
 
 
 
@@ -30,11 +30,14 @@ function myFunction() {
 💡 NOTE: you may use a for loop for this function if you wish 
 */
 
-function summation(/*Your Code Here*/) {
-  /*Your Code Here*/
-
+  function summation(number) {
+    let sum = 0;
+    for (let i = 1; i <= number; i++) {
+      sum += i;
+    }
+    return sum;
   }
- 
+  
 
 // 🦁🦁🦁 Topic 2: ADVANCED Array Methods 🦁🦁🦁
 // Given this zoo data from around the United States, follow the instructions below. Use the specific array methods in the requests below to solve the problems.
@@ -60,8 +63,12 @@ const zooAnimals = [
   💡 NOTE: the array returned should be an array of strings, and each string should follow this pattern: "name: {name}, scientific: {scientific name}"
   */
 
-  function animalNames(/*Your Code Here*/){
-    /*Your Code Here*/
+  function animalNames(zooAnimals, animal_name, scientific_name){
+    const newZooAnimals = [];
+    zooAnimals.forEach((animal_name, scientific_name) => {
+      newZooAnimals.push(animal_name, scientific_name)
+    });
+   return newZooAnimals `name: ${animal_name}, scientific: ${scientific_name}`
   }
   
 
@@ -75,10 +82,14 @@ const zooAnimals = [
   💡 NOTE: Do some research for other methods that can help help you
   */
 
-  function lowerCaseNames(/*Your Code Here*/){
-    /*Your Code Here*/
+  function lowerCaseNames(zooAnimals, animal_name){
+    let lowercased = zooAnimals.map(name => animal_name.toLowerCase());
+
+
+    // const lower = zooAnimals.map(lowerCaseNames.toLowerCase)
+    // return
   }
-  
+ 
   
   /* 🦁🦁🦁 Request 3: .filter() 🦁🦁🦁
   The zoo is concerned about animals with a lower population count. 
@@ -88,11 +99,12 @@ const zooAnimals = [
   3. Return this new array
   */
 
-  function lowPopulationAnimals(/*Your Code Here*/){
-    /*Your Code Here*/
+  function lowPopulationAnimals(zooAnimals, population){
+    const lowPop = zooAnimals.filter(checkLowPop(population));
+      function checkLowPop(population) {
+        return population < 5;
+      }
   }
-  
-
   /* 🦁🦁🦁 Request 4: .reduce() 🦁🦁🦁
   The zoo needs to know their total animal population across the United States. 
   USe USApop to do the following:
@@ -102,11 +114,14 @@ const zooAnimals = [
   💡 NOTE: Remember the reduce method takes two arguments: a callback (which itself takes two args - the accumulator and the item), and an initial value for the count. Check MDN/W3Schools for syntax!
   */
 
-  function USApop(/*Your Code Here*/){
-    /*Your Code Here*/
+  function USApop(zooAnimals, accumulator, currentVal){
+    const totalPop = zooAnimals.reduce((accumulator, currentVal) => {
+      return accumulator += currentVal.population
+    }, 0);
   }
   
   
+  
   // 🦁🦁🦁 Callbacks 🦁🦁🦁  
   /* 🦁🦁🦁 Step 1: Create a higher-order function 🦁🦁🦁
   Use the higher-order function called consume to do the following:
@@ -116,10 +131,9 @@ const zooAnimals = [
     💡 NOTE: The tests for 'consume' will pass if it is created correctly and also after you correctly complete the functions 'add' and 'greeting' below in Step 2.
   */
 
-  function consume(/*Your Code Here */){
-    /*Your Code Here */
+  function consume (a, b, cb) {
+    return cb(a, b)
   }
- 
   
   // 🦁🦁🦁 Step 2: Create several functions to callback with consume(); 🦁🦁🦁
 
@@ -128,8 +142,8 @@ const zooAnimals = [
  2. Return the sum of those numbers
  */
 
-function add(/*Your Code Here */){
-    /*Your Code Here*/
+function add(num1, num2){
+    return num1 + num2;
   }
 
 
@@ -138,8 +152,8 @@ function add(/*Your Code Here */){
 2. Return the product of those numbers
 */
 
-function multiply(/*Your Code Here */){
-   /*Your Code Here */
+function multiply(num1, num2){
+   return num1 * num2;
   }
 
 
@@ -149,16 +163,16 @@ function multiply(/*Your Code Here */){
 💡 NOTE: The string returned must match the format above or the test will not pass!
 */
 
-function greeting(/*Your Code Here */){
-   return /*Your Code Here */
+function greeting(firstName, lastName){
+   return `Hello ${firstName} ${lastName}, nice to meet you!`
   }
   
   
 // 🦁🦁🦁 Step 3: Check your work by un-commenting the following calls to consume(): 🦁🦁🦁 
 // ⬇️ ⬇️ ⬇️ ⬇️ ⬇️ ⬇️ ⬇️ ⬇️ ⬇️ ⬇️ ⬇️
-// console.log(consume(2, 2, add)); // 4
-// console.log(consume(10, 16, multiply)); // 160
-// console.log(consume("Mary", "Poppins", greeting)); // Hello Mary Poppins, nice to meet you!
+console.log(consume(2, 2, add)); // 4
+console.log(consume(10, 16, multiply)); // 160
+console.log(consume("Mary", "Poppins", greeting)); // Hello Mary Poppins, nice to meet you!
 
 
 
@@ -175,8 +189,10 @@ function greeting(/*Your Code Here */){
 - Instances of CuboidMaker should initialize `length`, `width` and `height` properties
 */
 
-function CuboidMaker(/*Your Code Here */){
-  /*Your Code Here */
+function CuboidMaker(obj) {
+  this.length = obj.length;
+  this.width = obj.width;
+  this.height = obj.height;
 }
 
 
@@ -184,10 +200,11 @@ function CuboidMaker(/*Your Code Here */){
   Create a method called volume using CuboidMaker's prototype that returns the volume of a given cuboid's length, width, and height
   💡 NOTE: Formula for cuboid volume: length * width * height   
 */
-
-
-
-
+function volume (length, width, height){
+  CuboidMaker.prototype.volume = function (length, width, height) {
+    length * width *  height
+  }
+}
 /* 🐴🐴🐴 Step 3: Surface Area Method 🐴🐴🐴
   Create another method called surfaceArea using CuboidMaker's prototype that returns the surface area of a given cuboid's length, width, and height. 
   💡 NOTE: Formula for cuboid surface area: 2 * (length * width + length * height + width * height)  

From 5e1f81e9dfa947b81fb95587719f3c66a954acf7 Mon Sep 17 00:00:00 2001
From: JT Coates <wyosred@yahoo.com>
Date: Sat, 26 Mar 2022 23:13:19 -0600
Subject: [PATCH 2/2] finished sprint challenge

---
 index.js | 57 +++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 34 insertions(+), 23 deletions(-)

diff --git a/index.js b/index.js
index 21b4330c4..8b4751ec6 100644
--- a/index.js
+++ b/index.js
@@ -63,15 +63,15 @@ const zooAnimals = [
   💡 NOTE: the array returned should be an array of strings, and each string should follow this pattern: "name: {name}, scientific: {scientific name}"
   */
 
-  function animalNames(zooAnimals, animal_name, scientific_name){
-    const newZooAnimals = [];
-    zooAnimals.forEach((animal_name, scientific_name) => {
-      newZooAnimals.push(animal_name, scientific_name)
+  function animalNames(zooAnimals) {
+    const displayNames = [];
+    zooAnimals.forEach(function(item) {
+      displayNames.push(`name: ${item.animal_name}, scientific: ${item.scientific_name}`);
     });
-   return newZooAnimals `name: ${animal_name}, scientific: ${scientific_name}`
+   return displayNames 
   }
   
-
+  
   /* 🦁🦁🦁 Request 2: .map() 🦁🦁🦁
   The zoo needs a list of all their animal's names converted to lower case. 
   Use lowerCaseNames to do the following:
@@ -82,9 +82,9 @@ const zooAnimals = [
   💡 NOTE: Do some research for other methods that can help help you
   */
 
-  function lowerCaseNames(zooAnimals, animal_name){
-    let lowercased = zooAnimals.map(name => animal_name.toLowerCase());
-
+  function lowerCaseNames(zooAnimals){
+    let lowerCased = zooAnimals.map(zooAnimals => zooAnimals.animal_name.toLowerCase());
+      return lowerCased
 
     // const lower = zooAnimals.map(lowerCaseNames.toLowerCase)
     // return
@@ -99,12 +99,12 @@ const zooAnimals = [
   3. Return this new array
   */
 
-  function lowPopulationAnimals(zooAnimals, population){
-    const lowPop = zooAnimals.filter(checkLowPop(population));
-      function checkLowPop(population) {
-        return population < 5;
-      }
-  }
+  function lowPopulationAnimals(zooAnimals){
+    const lowPop = zooAnimals.filter(function(item){
+      return item.population <= 5
+    }) 
+      return lowPop
+  } 
   /* 🦁🦁🦁 Request 4: .reduce() 🦁🦁🦁
   The zoo needs to know their total animal population across the United States. 
   USe USApop to do the following:
@@ -114,10 +114,11 @@ const zooAnimals = [
   💡 NOTE: Remember the reduce method takes two arguments: a callback (which itself takes two args - the accumulator and the item), and an initial value for the count. Check MDN/W3Schools for syntax!
   */
 
-  function USApop(zooAnimals, accumulator, currentVal){
+  function USApop(zooAnimals){
     const totalPop = zooAnimals.reduce((accumulator, currentVal) => {
       return accumulator += currentVal.population
     }, 0);
+    return totalPop
   }
   
   
@@ -200,16 +201,17 @@ function CuboidMaker(obj) {
   Create a method called volume using CuboidMaker's prototype that returns the volume of a given cuboid's length, width, and height
   💡 NOTE: Formula for cuboid volume: length * width * height   
 */
-function volume (length, width, height){
-  CuboidMaker.prototype.volume = function (length, width, height) {
-    length * width *  height
-  }
+CuboidMaker.prototype.volume = function(){
+  return this.length * this.width * this.height
 }
+  
 /* 🐴🐴🐴 Step 3: Surface Area Method 🐴🐴🐴
   Create another method called surfaceArea using CuboidMaker's prototype that returns the surface area of a given cuboid's length, width, and height. 
   💡 NOTE: Formula for cuboid surface area: 2 * (length * width + length * height + width * height)  
 */
-
+CuboidMaker.prototype.surfaceArea = function(){
+  return 2 * (this.length * this.width + this.length * this.height + this.width * this.height)
+}
 
 
 
@@ -231,12 +233,21 @@ function volume (length, width, height){
 //Using CuboidMakerTwo, take your prototypes from above and refactor into class syntax. Then, create an object called cuboidTwo that uses the new keyword to use our CuboidMakerTwo class.
  
 class CuboidMakerTwo{
-
+  constructor(attrs){
+    this.length = attrs.length;
+    this.width = attrs.width;
+    this.height = attrs.height;
+} 
+volume(){
+  return this.length * this.width * this.height
+  }
+  surfaceArea() {
+    return 2 * (this.length * this.width + this.length * this.height + this.width * this.height)
+  }
 }
 
 
 
-
 //🦄🦄🦄 Test your volume and surfaceArea methods by uncommenting the logs below: 🦄🦄🦄
 // console.log(cuboidTwo.volume()); // 100
 // console.log(cuboidTwo.surfaceArea()); // 130