For this exercise, if I use this.breed (as I should) I receive an error, but if I use breed (which is, by my understanding, incorrect) I pass the exercise?
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 " + this.breed + " dog"); // supposedly correct usage that gives me an error
};
var yourDog = new Dog("golden retriever");
yourDog.sayHello();
var myDog = new Dog("dachshund");
myDog.sayHello();
If instead I use breed then I receive ReferenceError: breed is not defined but the exercise says Way to Go!
Okay, so adding the adid allow my code to pass. So my bad on that one. However, 1. the output didn’t show up in the console and 2. the incorrect code of just using breed still passes, even though the console throws an error. I used 2 different browsers.
(My method is to test this is to reset the code, click the button to submit exercise, get an error, paste in the code I’m testing, submit again.)