"Hello, this is a [breed] dog" URGENT


#1


https://www.codecademy.com/courses/objects-ii/5/2?curriculum_id=506324b3a7dffd00020bf661#


In the exercise where you have to make the sayHello prototype, I received this error message: Oops, try again. It appears that your sayHello method doesn't properly log to the console 'Hello this is a [breed] dog' where [breed] is the breed of the Dog. However, the two things printed to the console were:

Hello, this is a golden retriever dog
Hello, this is a dachshund dog

Here is my code:

function Dog (breed) {
    this.breed = breed;
};

// add the sayHello method to the Dog class 
// so all dogs now can say hello
Dog.prototype.sayHello = function(){
console.log("Hello, this is a " + this.breed + " dog");    
};

var yourDog = new Dog("golden retriever");
yourDog.sayHello();

var myDog = new Dog("dachshund");
myDog.sayHello();


#2

Hi,

the issue is on your 8 line: "console.log("Hello, this is a " + this.breed + " dog"); ", remove comma after "Hello", because it was not specified in the instructions for this task. Therefore you have a mismatch on the code.

here is corrected code:

function Dog (breed) {
this.breed = breed;
};

// add the sayHello method to the Dog class
// so all dogs now can say hello
Dog.prototype.sayHello = function() {
console.log("Hello this is a " + this.breed + " dog");
}

var yourDog = new Dog("golden retriever");
yourDog.sayHello();

var myDog = new Dog("dachshund");
myDog.sayHello();


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.