28. H3llo? Yes, this is dog


It says I'm doing it right but it also says error: breed is not defined. Why is this?

Here's 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 " + breed + "dog");

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

var myDog = new Dog("dachshund");



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

there is a reason you do this, its because now in other methods you can access breed through self


I agree with the last comment, but I will add also:
"dog" >>> " dog"


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