Skip to content
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

Chandra Dhopatkar #1248

Open
wants to merge 5 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
38 changes: 30 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,49 @@ Edit this document to include your answers after each question. Make sure to lea

1. Briefly compare and contrast `.forEach` & `.map` (2-3 sentences max)

The map method receives a function as a parameter. Then it applies it on each element and returns an entirely new array populated with the results of calling the provided function. Like map , the forEach() method receives a function as an argument and executes it once for each array element. However, instead of returning a new array like map, it returns undefined.

2. Explain the difference between a callback and a higher order function.

A higher-order function is a function that takes another function(s) as an argument(s) and/or returns a function to its callers.

A callback function is a function that is passed to another function with the expectation that the other function will call it.

3. What is closure?

A closure is a feature in JavaScript where an inner function has access to the outer (enclosing) function’s variables — a scope chain.



4. Describe the four rules of the 'this' keyword.

Whenever a function is contained in the global scope, the value of this inside of that function will be the window object.

Whenever a function is called by a preceding dot, the object before that dot is this.

Whenever a constructor function is used, this refers to the specific instance of the object that is created and returned by the constructor function.

Whenever JavaScript’s call or apply method is used, this is explicitly defined.



5. Why do we need super() in an extended class?

The super keyword in JavaScript is used in order to call the methods of the parent class. By itself, super() is used within a constructor function to call the parent constructor function.

### Task 1 - Project Set up

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.
- [ ] 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>`.
- [ done] Create a forked copy of this project.
- [ done ] Add TL as collaborator on Github.
- [ done ] Clone your OWN version of Repo (Not Lambda's by mistake!).
- [ done ] Create a new Branch on the clone: git checkout -b `<firstName-lastName>`.
- [ done ] Create a pull request before you start working on the project requirements. You will continuously push your updates throughout the project.
- [ done ] You are now ready to build this project with your preferred IDE
- [ done ] Implement the project on your Branch, committing changes regularly.
- [ done ] Push commits: git push origin `<firstName-lastName>`.



Expand Down
8 changes: 7 additions & 1 deletion challenges/arrays-callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@ const zooAnimals = [
The zoos want to display both the scientific name and the animal name in front of the habitats. Populate the displayNames array with only the animal_name and scientific_name of each animal. displayNames will be an array of strings, and each string should follow this pattern: "Name: Jackal, asiatic, Scientific: Canis aureus."

*/
const displayNames = [];

zooAnimals.forEach(function(displayNames){


const displayNames = [animal_name, scientific_name];
console.log(displayNames);

});

/* Request 2: .map()

The zoos need a list of all their animal's names (animal_name only) converted to lower case. Using map, create a new array of strings named lowCaseAnimalNames, each string following this pattern: "jackal, asiatic". Log the resut.
Expand Down
24 changes: 24 additions & 0 deletions challenges/classes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
// 1. Copy and paste your prototype in here and refactor into class syntax.

function CupoidMaker(attributes) {
this.length = attributes.length;
this.width = attributes.width;
this.height = attributes.height;
}

CupoidMaker.prototype.volume = function () {
return (length*width*height);
};


class CupoidMaker {
constructor(attributes) {
this.length = attributes.length;
this.width = attributes.width;
this.height = attributes.height;
}
volume() {
return (length*witdth*height)
}
}



// Test your volume and surfaceArea methods by uncommenting the logs below:
// console.log(cuboid.volume()); // 100
// console.log(cuboid.surfaceArea()); // 130
Expand Down
11 changes: 10 additions & 1 deletion challenges/closure.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,18 @@ function myFunction() {
}
myFunction();

// Explanation:
// Explanation: Internal is located within the nested function, so it is within the scope, therefore can be accessed.


/* Task 2: Counter */

/* Create a function called `sumation` that accepts a parameter and uses a counter to return the summation of that number. For example, `summation(4)` should return 10 because 1+2+3+4 is 10. */

function summation(a) {

return function(b) {
return a + b; // takes "a" from the outer lexical environment
};

}

12 changes: 12 additions & 0 deletions challenges/prototypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,25 @@
Create a constructor function named CuboidMaker that accepts properties for length, width, and height
*/

function CupoidMaker(length, width, height) {
this.length = length;
this.width = width;
this.height = height;

}

/* == Step 2: Volume Method ==
Create a method using CuboidMaker's prototype that returns the volume of a given cuboid's length, width, and height

Formula for cuboid volume: length * width * height
*/
function CupoidMaker(length, width, height) {
this.length = length;
this.width = width;
this.height = height;
}

CupoidMaker.prototype.volume = (length * width * height);

/* == Step 3: Surface Area Method ==
Create another method using CuboidMaker's prototype that returns the surface area of a given cuboid's length, width, and height.
Expand Down