Hello? Yes, This is Dog... breed is not defined


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 " + [breed] + " dog");

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

var myDog = new Dog("dachshund");

So I have just completed this exercise with the above code and I can continue onto the next exercise no problem but the console is logging an error message instead of the dogs' breeds and I just wanted to know why??

The error message is "ReferenceError: breed is not defined"

Why is it not defined??


you need to use this.breed, you have access to this variable thanks to this


So it's suppose to be:

console.log("Hello this is a " + this.breed + " dog"); ???


well yes? You make breed accessible in the object with this.breed thanks to this line:

this.breed = breed;

so it makes sense to use this.breed


Awesome thanks :smile: