IM getting error msg on my answerr? (jave script)
faziz6006 (2)

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


my code :

AnimalClass.prototype.speak = function(says){
this.speak = 'says';
return this.name + ' ' + this.speak + '' + this.noise;
};

error msg i keep getting :
Should add a method to the prototype called speak

You are viewing a single comment. View All
theangryepicbanana (833)

do this.speak = says; instead of this.speak = 'says'; because 'says' is a string, but says gets the actual value of the parameter called says

faziz6006 (2)

@theangryepicbanana i changed it to :

AnimalClass.prototype.speak = function(says){
this.speak = says;
return this.name + '' + this.speak + '' + this.noise;
};

still error : Should add a method to the prototype called speak