Breed is not defined


28. Hello. Yes, this is Dog

Receiving error message "ReferenceError: breed is not defined" but allows me to pass . Have tried adding "this.breed" and it gives me this error. "
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" and won't let me pass.

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;

you make breed accessible through this, so you can this.breed inside methods

also, there shouldn't be a full stop after dog when logging that sentence to the console


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