Created
April 2, 2019 00:04
-
-
Save dangolbeeker/e5faf44161cc5512c3d017dc79cfd901 to your computer and use it in GitHub Desktop.
JS Assignment 14: The Class `prototype` created by dangolbeeker - https://repl.it/@dangolbeeker/JS-Assignment-14-The-Class-prototype
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function exerciseOne(UserClass){ | |
// Exercise One: In this exercise you are given a class called UserClass. | |
// You will be adding a method to the prototype called greeting | |
// This method will return the string: 'Hello, it is nice to meet you!' | |
// DO NOT create a new class or object | |
UserClass.prototype.greeting = function(){ | |
return 'Hello, it is nice to meet you!'; | |
}; | |
// Please write your code in the lines above | |
return UserClass; | |
} | |
function exerciseTwo(AnimalClass){ | |
// Exercise Two: In this exercise you are given a class called AnimalClass. | |
// The class will already have the properties 'name', 'noise' on it. | |
// You will be adding a method to the prototype called 'speak' | |
// Using the 'this' keyword, speak should return the following string: | |
// '<name> says <noise>' | |
// DO NOT create a new class or object | |
AnimalClass.prototype.speak = function(){ | |
return `${this.name} says ${this.noise}`; | |
}; | |
// Please write your code in the lines above | |
return AnimalClass; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment