Lajawanti-Dhake - #683
Open
innovationcode wants to merge 9 commits into
Open
Conversation
mmargo10
reviewed
Sep 14, 2018
| 2) What is the difference between a function and a method? | ||
| --> In programming, function is a named section of a program that performs a specific task. In javascript you can define function | ||
| anywhere in your program because of HOISITNG. | ||
| A function defined inside of an object is known as method. |
| --> .forEach() works similar as for loop, using .forEach() you can iterate through every element in the array, .forEach() method doesn’t | ||
| return anything. | ||
| .map() method will also call a provided function on every element in the array. The difference is that map() utilizes return values | ||
| and actually returns a new Array of the same size. |
|
|
||
| 3) What is closure? | ||
| --> A closure is an inner function that has access to the outer (enclosing) function's variables—scope chain. The closure has three | ||
| scope chains: it has access to its own scope (variables defined between its curly brackets), it has access to the outer function's variables, and it has access to the global variables. |
| We call these explicit because you are explicitly passing in a this context to call() or apply(). | ||
|
|
||
| new Binding : whenever we’ve got a function invoked with the new operator, the this keyword here is bound to the new object being | ||
| built by the function constructor. |
| const cube = new CubeMaker(5); | ||
| console.log(cube); | ||
| console.log(cube.volume()); // 125 | ||
| console.log(cube.surfaceArea()); // 150 No newline at end of file |
There was a problem hiding this comment.
Well done. You completed each task correctly.
| 'roar' : function() { | ||
| return "RAWERSRARARWERSARARARRRR!"; | ||
| } | ||
| }; |
There was a problem hiding this comment.
I would suggest that in future you use const or let instead of var.
| 'period' : 'Late Cretaceious' | ||
| }; | ||
|
|
||
| // Using your dinosaur objects, log answers to these questions: |
| Once you have the new array created, sort the universities alphabetically and log the result. */ | ||
| const universities = []; | ||
| console.log(universities) | ||
| const universities = graduates.map(function(element) { |
There was a problem hiding this comment.
Your answer is a correct use of .map, however you were instructed to NOT use any array methods. A for loop would have been the correct answer.
| const populationTotal = zooAnimals.reduce(function(total, animalPopulation) { | ||
| return total + animalPopulation.population; | ||
| },0); | ||
| console.log(populationTotal) No newline at end of file |
There was a problem hiding this comment.
The answers to the zoo animals questions are correct.
| this.length = length; | ||
| this.width = width; | ||
| this.height = height; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@mmargo10 "Sprint-challenge-Javascript"