JS Assignment 14 The Class Prototype
Exit (2)

I’m having difficulty understanding how to solve the second exercise. I watched and read through the lesson, but can’t find where it teaches to add a method to a prototype.
Any help would be wonderful

You are viewing a single comment. View All
heyitsmarcus (326)

It looks like there is one major error where you're missing a + on this line:

this.speak = name + 'says' noise;

Change to:

//You need a + between 'says' and noise
//But also, you'll likely need the extra spaces in ' says ' because otherwise 
//the sentence will be jumbled together instead of evenly spaced as it 
//should be
this.speak = name + ' says ' + noise;

Or, in the latest JavaScript syntax:

//The newest syntax makes it easier to see what the sentence will look like
//when it is returned
this.speak = `${name} says ${noise}`;

If this solved your problem, please consider marking my answer as the accepted answer to close this question. If you have any further questions on this, I'll answer those still.