Skip to content

Commit

Permalink
Homework Lesson 08
Browse files Browse the repository at this point in the history
  • Loading branch information
Shayne Smith committed Jan 21, 2020
1 parent 2c6b989 commit c8ff530
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion Lesson08-JS-V/homework/homework.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,26 @@ function createUserClass() {
// the constructor should have a method 'sayHi' on its prototype that returns the string 'Hello, my name is {{name}}'
// {{name}} should be the name set on each instance
// return the class
function User(options) {
this.username = options.username;
this.name = options.name;
this.email = options.email;
this.password = options.password;
}

User.prototype.sayHi = function () {
return 'Hello, my name is ' + this.name;
};

return User;
}

function addPrototypeMethod(Constructor) {
// add a method to the constructor's prototype
// the method should be called 'sayHi' and should return the string 'Hello World!'
Constructor.prototype.sayHi = function () {
return 'Hello World!';
};
}

function addReverseString() {
Expand All @@ -21,11 +36,19 @@ function addReverseString() {
// you will need to use 'this' inside of reverse
}

addReverseString.prototype.reverse = function () {
let reverseString = '';
for (let i = 0; i < this.length; i++) {
reverseString = reverseString + reverseString[this.length - (i + 1)];
}
return reverseString;
};

// Do not modify code below this line.
// --------------------------------

module.exports = {
createUserClass,
addPrototypeMethod,
addReverseString,
};
};

0 comments on commit c8ff530

Please sign in to comment.