File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 GameObject
77 createdAt
88 dimensions
9- destroy() // prototype method -> returns the string 'Game object was removed from the game.'
9+ destroy() // prototype method -> returns the string 'Game object was removed from the game.' */
10+
11+ /*
1012
1113 NPC
1214 hp
Original file line number Diff line number Diff line change 77class User {
88 constructor ( options ) {
99 // set a username and password property on the user object that is created
10+ this . username = options . username ;
11+ this . password = options . password ;
1012 }
13+ /*
14+ checkPassword(pass) {
15+ return pass === this.password;
16+ }
17+
1118 // create a method on the User class called `checkPassword`
1219 // this method should take in a string and compare it to the object's password property
1320 // return `true` if they match, otherwise return `false`
1421}
15-
22+ */
23+ }
1624const me = new User ( {
1725 username : 'LambdaSchool' ,
1826 password : 'correcthorsebatterystaple' ,
1927} ) ;
2028
21- const result = me . checkPassword ( 'correcthorsebatterystaple' ) ; // should return `true`
29+ // const result = me.checkPassword('correcthorsebatterystaple'); // should return `true`
2230
2331/* part 2 */
2432
@@ -27,8 +35,12 @@ const checkPassword = function comparePasswords(passwordToCompare) {
2735 // use `this` to access the object's `password` property.
2836 // do not modify this function's parameters
2937 // note that we use the `function` keyword and not `=>`
38+ return this . password === passwordToCompare ;
3039} ;
3140
41+ User . prototype . checkPassword = checkPassword ;
42+ console . log ( me . checkPassword ( 'correcthorsebatterystaple' ) ) ;
43+
3244// invoke `checkPassword` on `me` by explicitly setting the `this` context
3345// use .call, .apply, and .bind
3446
You can’t perform that action at this time.
0 commit comments