README Questions complete - Marcus Bass - #555
Conversation
Comprehension Questions
Objects and Arrays
Functions
Prototypes
Classes
|
mykeal-kenny
left a comment
There was a problem hiding this comment.
Good job! Just a few things here and there to work on, but, I know it was a hard week for you.
|
|
||
| ## Task 2: Comprehension Questions | ||
| Answer the following questions to the best of your ability. You can exercise your Googling skills and use training kit. Open up the [Answers.md](Answers.md) file and record your responses there. | ||
|
|
There was a problem hiding this comment.
Try to answer the questions in the Answers.md file next time. It will make it easier for both of us, good answers though!
| Answer the following questions to the best of your ability. You can exercise your Googling skills and use training kit. Open up the [Answers.md](Answers.md) file and record your responses there. | ||
|
|
||
| 1. Describe the biggest difference between `.forEach` & `.map`: forEach applies to every item in an array and doesn't return anything, map returns an array of the same size. | ||
|
|
There was a problem hiding this comment.
The biggest takeaway from that should be:
forEach manipulates the array while map makes a copy.
there will be instances where you don't want to mess with the original
| 1. Describe the biggest difference between `.forEach` & `.map`: forEach applies to every item in an array and doesn't return anything, map returns an array of the same size. | ||
|
|
||
| 2. What is the difference between a function and a method? A function is used to return a value (IE string, number, etc). A method is like a function, but it's an internal part of a class. | ||
|
|
| 2. What is the difference between a function and a method? A function is used to return a value (IE string, number, etc). A method is like a function, but it's an internal part of a class. | ||
|
|
||
| 3. What is closure? Closure is an inner function that has access to the outer | ||
|
|
There was a problem hiding this comment.
How does it work? Could you explain it to a 10 year old? That's the biggest test of whether or not you get something.
|
|
||
| 3. What is closure? Closure is an inner function that has access to the outer | ||
|
|
||
| 4. Describe the four rules of the 'this' keyword. |
There was a problem hiding this comment.
Perfect! Keep these in mind as everything else will build on these concepts. THIS, while being ridiculous in it's own way, will definitely make things easier to understand later on.
| 3 - When a dot is to the left of a function invocation, this is the object to the left of the dot | ||
| 4 - A function without any conditions is the global object or in a browser, a window. | ||
|
|
||
| 5. Why do we need super() in an extended class? That's the proper way to call functions on the object's parent? Super is used for when you want to use the methods and properties of parent class. |
There was a problem hiding this comment.
Partially, but good enough for a working understanding. I would recommend reading up on the concept as it's very much an important thing to know.
| } | ||
| // Getter | ||
| get volume() { | ||
| return this.calcArea(); |
There was a problem hiding this comment.
It works! But, the function name is misleading I wasn't paying attention.
| (this.length * this.width + | ||
| this.length * this.height + | ||
| this.width * this.height) | ||
| ); |
There was a problem hiding this comment.
consider refactoring for a cleaner flow. while it does work and it does make sense, I think you can make it look better.
| // How long was a stegosaurus? | ||
| var stegosaurus = {diet:"herbivorous", weight:"2000kg", length: "9m", period: "Late Jurassic"}; | ||
| console.log(stegosaurus.length); | ||
| // What time period did tyrannosaurus live in? |
| Add properties and values of length: 4, width: 5, and height: 5 to cuboid. | ||
| */ | ||
| Create a cuboid object that uses the new keyword to use our CuboidMaker constructor | ||
| Add properties and values of length: 4, width: 5, and height: 5 to cuboid. |
There was a problem hiding this comment.
Work on your prototypes a little more maybe? Please hit me up if you don't understand!
@fireinjun