Amir yunas - #1
Conversation
… animals in the zoo. completed objects-arrays.js
…as input. created 3 cb functions: add/multiply/greeting.
jheinz1999
left a comment
There was a problem hiding this comment.
Everything is looking really good! The only things that are missing are prototypes and the readme questions. Try your best with prototypes, and definitely use the guided project and solution code for JS 3 if you get stuck!
|
|
||
|
|
||
| // tyrannosaurus, carnivorous, 7000kg, 12m, Late Cretaceious | ||
| const tyrannosaurus = { |
There was a problem hiding this comment.
Excellent work creating objects!
| console.log(tyrannosaurus.period); | ||
|
|
||
|
|
||
| // Create a new roar method for the tyrannosaurus. When called, return "RAWERSRARARWERSARARARRRR!" Log the result. |
There was a problem hiding this comment.
Make sure to add the roar method!
| */ | ||
| const animalNames = []; | ||
|
|
||
| zooAnimals.forEach( (animal,i) => animalNames.push('Name: ' + zooAnimals[i].animal_name,'Scientific: ' + zooAnimals[i].scientific_name)); |
There was a problem hiding this comment.
Awesome that you are using arrow syntax!
|
|
||
| const lowerCase = []; | ||
|
|
||
| zooAnimals.forEach( (animal,i) => lowerCase.push(zooAnimals[i].animal_name.toLowerCase())); |
There was a problem hiding this comment.
This challenge is asking you to use .map()
| console.log(largerPopulation); | ||
|
|
||
| const smallerPopulation = zooAnimals.filter((animal,i) => zooAnimals[i].population < 5); | ||
| const smallerNames = smallerPopulation.map( (animal,i) => (`${smallerPopulation[i].animal_name}, Population: ${smallerPopulation[i].population}`)); |
There was a problem hiding this comment.
It's awesome that you used .map() here for better formatting! Know that you don't need to create a separate variable here, as you can just chain the .map() method on after your .filter() method.
| // Explain in your own words why `nestedfunction()` can access the variable `internal`. | ||
|
|
||
| // Explanation: | ||
| console.log(`Explanation: nestedFunction() is able to access the variable internal, even though it is outside of the function scope. This is because of the concept in javascript known as a closure. Javascript allows for this behavior in order to allow functions to behave correctly. Technically, a function cannot access variables outside of it's scope. But because of the closure, a nested function can access variables in functions outside of it, and even in the global context.\n`); |
There was a problem hiding this comment.
This is an excellent answer!
|
|
||
| class CuboidMaker { | ||
| constructor(keys) { | ||
| this.name = keys.name; |
There was a problem hiding this comment.
Awesome that you added an additional property here
…as unable to commit the changes to git.
…oAnimals array instead of creating another array and running an array method on each variable array.
|
I just commited the changes that you suggested and the readme file has been pushed correctly. Please re-review. Thanks! |
jheinz1999
left a comment
There was a problem hiding this comment.
Excellent work! The only thing that you're missing is prototypes, which we will talk about
| @@ -29,15 +29,27 @@ Demonstrate your understanding of this week's concepts by answering the followin | |||
| Edit this document to include your answers after each question. Make sure to leave a blank line above and below your answer so it is clear and easy to read by your project manager | |||
|
|
|||
| 1. Describe the biggest difference between `.forEach` & `.map`. | |||
| weight: '7000kg', | ||
| length: '12m', | ||
| period: 'Late Cretaceious', | ||
| roar: function() {return 'RAWERSRARARWERSARARARRRR!'} |
There was a problem hiding this comment.
Awesome work adding in the roar method!
| const lowerCase = []; | ||
| //zooAnimals.forEach( (animal,i) => lowerCase.push(zooAnimals[i].animal_name.toLowerCase())); | ||
|
|
||
| const lowerCase = zooAnimals.map( (animal,i) => animal.animal_name.toLowerCase() ); |
There was a problem hiding this comment.
Looking good! It doesn't look like you're using the second parameter in your callback function, so you could remove it
@jheinz1999
Project ifnished! prototypes.js file not done. please see message.