diff --git a/README.md b/README.md index cc6d6902fb..d9982bdaf7 100644 --- a/README.md +++ b/README.md @@ -39,11 +39,11 @@ Edit this document to include your answers after each question. Make sure to lea Follow these steps to set up and work on your project: Make sure you clone the branch that the TK links to: the vnext branch, NOT master! -- [ ] Create a forked copy of this project. -- [ ] Add TL as collaborator on Github. -- [ ] Clone your OWN version of Repo (Not Lambda's by mistake!). -- [ ] Create a new Branch on the clone: git checkout -b ``. -- [ ] Create a pull request before you start working on the project requirements. You will continuously push your updates throughout the project. +- [x] Create a forked copy of this project. +- [x] Add TL as collaborator on Github. +- [x] Clone your OWN version of Repo (Not Lambda's by mistake!). +- [x] Create a new Branch on the clone: git checkout -b ``. +- [] Create a pull request before you start working on the project requirements. You will continuously push your updates throughout the project. - [ ] You are now ready to build this project with your preferred IDE - [ ] Implement the project on your Branch, committing changes regularly. - [ ] Push commits: git push origin ``. diff --git a/challenges/arrays-callbacks.js b/challenges/arrays-callbacks.js index 472ab3e96d..069e486016 100644 --- a/challenges/arrays-callbacks.js +++ b/challenges/arrays-callbacks.js @@ -21,6 +21,10 @@ The zoos want to display both the scientific name and the animal name in front o */ const displayNames = []; +zooAnimals.forEach(function(item){ + displayNames.push(item.animal_name `Name:${"animal_name"}`); + displayNames.push(item.scientific_name `Scientific:${"scientific_name"}`); + }); console.log(displayNames); /* Request 2: .map() @@ -30,7 +34,10 @@ The zoos need a list of all their animal's names (animal_name only) converted to */ const lowCaseAnimalNames = []; -console.log(lowCaseAnimalNames); +zooAnimals.map(function(myArray){ + lowCaseAnimalNames.push(myArray.animal_name.toLowerCase()); +}); +console.log(lowCaseAnimalNames); /* Request 3: .filter() @@ -38,6 +45,15 @@ The zoos are concerned about animals with a lower population count. Using filter */ const lowPopulationAnimals = []; +function getPop(item){ + const result = zooAnimals.filter(function(item){ + if ( + population < 5 + ){ + result.push.lowPopulationAnimals + } + }); +} console.log(lowPopulationAnimals); /* Request 4: .reduce() @@ -46,6 +62,9 @@ The zoos need to know their total animal population across the United States. Fi */ const populationTotal = 0; +function totalAnimalPop(item){ + const result = zooAnimals.reduce(callback, value) +} console.log(populationTotal); @@ -57,6 +76,9 @@ console.log(populationTotal); * The last parameter accepts a callback * The consume function should return the invocation of cb, passing a and b into cb as arguments */ +function consume(a, b, cb){ +return cb(a,b); +} /* Step 2: Create several functions to callback with consume(); @@ -64,13 +86,19 @@ console.log(populationTotal); * Create a function named multiply that returns the product of two numbers * Create a function named greeting that accepts a first and last name and returns "Hello first-name last-name, nice to meet you!" */ +function add(num1, num2){ + const sum = num1 + num2 + return sum +} +function greeting(first, last){ + return `Hello ${first} ${last}, 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! diff --git a/challenges/index.html b/challenges/index.html index 5772804b7f..0dc5ec27dd 100644 --- a/challenges/index.html +++ b/challenges/index.html @@ -7,8 +7,8 @@ Sprint Challenge - - + +