Skip to content

Began sprint #1254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<firstName-lastName>`.
- [ ] 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 `<firstName-lastName>`.
- [] 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 `<firstName-lastName>`.
Expand Down
38 changes: 33 additions & 5 deletions challenges/arrays-callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -30,14 +34,26 @@ 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()

The zoos are concerned about animals with a lower population count. Using filter, create a new array of objects called lowPopulationAnimals which contains only the animals with a population less than 5.

*/
const lowPopulationAnimals = [];
function getPop(item){
const result = zooAnimals.filter(function(item){
if (
population < 5
){
result.push.lowPopulationAnimals
}
});
}
console.log(lowPopulationAnimals);

/* Request 4: .reduce()
Expand All @@ -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);


Expand All @@ -57,20 +76,29 @@ 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();
* Create a function named add that returns the sum of two numbers
* 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!



Expand Down
4 changes: 2 additions & 2 deletions challenges/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

<title>Sprint Challenge</title>

<script src="objects-arrays.js"></script>
<script src="functions.js"></script>
<script src="arrays-callbacks.js"></script>
<script src="closure.js"></script>
<script src="prototypes.js"></script>
<script src="classes.js"></script>
</head>
Expand Down