diff --git a/Chapter 7/Exercise 7.3 b/Chapter 7/Exercise 7.3 new file mode 100644 index 0000000..9923d99 --- /dev/null +++ b/Chapter 7/Exercise 7.3 @@ -0,0 +1,17 @@ +class Animal { + constructor(species, sounds) { + this.species = species; + this.sounds = sounds; + } + speak() { + console.log(this.species + " " + this.sounds); + } +} +Animal.prototype.eat = function () { + return this.species + " is eating"; +} +let cat = new Animal("cat", "meow"); +let dog = new Animal("dog", "bark"); +cat.speak(); +console.log(dog.eat()); +console.log(dog);