Hello? Yes, This is Dog


#1


keeps saying
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
please help

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

new 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();

whats wrong


#3

Your first code is pretty good, you just need to add a space between a and this.breed:

Dog.prototype.sayHello = function() {
    console.log("Hello this is a " + this.breed + " dog");
}

In the second code, you can't just write something like 12 35 or "John" "Tom", these values must he somehow joined. You need to add a plus sign between " " and this.breed.


#4

Thanks alot for your help mate


#5

You're very welcome :slight_smile:


#6

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