Skip to content

Commit 413a1ce

Browse files
committed
completed this.js
1 parent 33d1564 commit 413a1ce

2 files changed

Lines changed: 51 additions & 27 deletions

File tree

README.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,38 @@
11
# JavaScript - III
22

3+
Jose Montero Jr
4+
35
This challenge focuses on using the `this` keyword as well as getting comfortable with prototypes by building out a fantasy themed video game.
46

57
## Set Up The Project With Git
68

79
**Follow these steps to set up and work on your project:**
810

9-
* [ ] Create a forked copy of this project.
10-
* [ ] Add your project manager as collaborator on Github.
11-
* [ ] Clone your OWN version of the repository (Not Lambda's by mistake!).
12-
* [ ] Create a new branch: git checkout -b `<firstName-lastName>`.
13-
* [ ] Implement the project on your newly created `<firstName-lastName>` branch, committing changes regularly.
14-
* [ ] Push commits: git push origin `<firstName-lastName>`.
11+
- [x] Create a forked copy of this project.
12+
- [x] Add your project manager as collaborator on Github.
13+
- [x] Clone your OWN version of the repository (Not Lambda's by mistake!).
14+
- [x] Create a new branch: git checkout -b `<firstName-lastName>`.
15+
- [x] Implement the project on your newly created `<firstName-lastName>` branch, committing changes regularly.
16+
- [x] Push commits: git push origin `<firstName-lastName>`.
1517

1618
**Follow these steps for completing your project.**
1719

18-
* [ ] Submit a Pull-Request to merge <firstName-lastName> Branch into master (student's Repo). **Please don't merge your own pull request**
19-
* [ ] Add your project manager as a reviewer on the pull-request
20-
* [ ] Your project manager will count the project as complete by merging the branch back into master.
20+
- [x] Submit a Pull-Request to merge <firstName-lastName> Branch into master (student's Repo). **Please don't merge your own pull request**
21+
- [x] Add your project manager as a reviewer on the pull-request
22+
- [x] Your project manager will count the project as complete by merging the branch back into master.
2123

2224
## Assignment Set Up
2325

24-
* Complete all the exercises as described inside each assignment file.
25-
* To test your `console.log()` statements, open up the index.html file found in the assignments folder and use the developer tools to view the console.
26+
- Complete all the exercises as described inside each assignment file.
27+
- To test your `console.log()` statements, open up the index.html file found in the assignments folder and use the developer tools to view the console.
2628

2729
## The `this` keyword
2830

2931
Having a solid understanding of how `this` works will give you a huge advantage when you start building with more advanced frameworks. Use the [this.js](assignments/this.js) file to traverse through a few `this` problems.
3032

3133
## Prototype
3234

33-
The prototype challenge will focus on building prototypes for a fantasy themed game that includes mages, swordsmen, and archers. Follow the [prototypes.js](assignments/this.js) instructions closely to create the beginnings of what could be an awesome JavaScript game.
35+
The prototype challenge will focus on building prototypes for a fantasy themed game that includes mages, swordsmen, and archers. Follow the [prototypes.js](assignments/this.js) instructions closely to create the beginnings of what could be an awesome JavaScript game.
3436

35-
* Read the instructions found within the file carefully to finish the challenges.
36-
* Remember to un-comment the objects and console logs to test your work at the bottom of the page.
37+
- Read the instructions found within the file carefully to finish the challenges.
38+
- Remember to un-comment the objects and console logs to test your work at the bottom of the page.

assignments/this.js

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,48 @@
11
/* The for principles of "this";
2-
* in your own words. explain the four principle for the "this" keyword below.
3-
*
4-
* 1.
5-
* 2.
6-
* 3.
7-
* 4.
8-
*
9-
* write out a code example of each explanation above
10-
*/
2+
* in your own words. explain the four principle for the "this" keyword below.
3+
*
4+
* 1. window binding
5+
* 2. implicit binding
6+
* 3. new binding
7+
* 4. explicit binding
8+
*
9+
* write out a code example of each explanation above
10+
*/
1111

1212
// Principle 1
1313

14-
// code example for Window Binding
14+
// function myName(name) {
15+
// console.log(this);
16+
// return name;
17+
// }
18+
// myName('Jose');
1519

1620
// Principle 2
1721

18-
// code example for Implicit Binding
22+
const object = {
23+
greeting: 'Hi',
24+
sayHello: function(name) {
25+
console.log(`${this.greeting} my name is ${name}`);
26+
}
27+
};
28+
object.sayHello('Jose');
1929

2030
// Principle 3
2131

22-
// code example for New Binding
32+
function baseballPlayer(player) {
33+
this.greeting = ' is good at baseball';
34+
this.player = player;
35+
this.speak = function() {
36+
console.log(this.player + this.greeting);
37+
};
38+
}
39+
40+
const anthonyRizzo = new baseballPlayer('Rizzo');
41+
const krisBrant = new baseballPlayer('KB');
42+
anthonyRizzo.speak();
43+
krisBrant.speak();
2344

2445
// Principle 4
2546

26-
// code example for Explicit Binding
47+
anthonyRizzo.speak.call(krisBrant);
48+
krisBrant.speak.apply(anthonyRizzo);

0 commit comments

Comments
 (0)