28/30: Is this a bug or am I doing something wrong here?

sct

#1

https://www.codecademy.com/en/courses/objects-ii/5/2

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!


#2
"Hello this is a " + this.breed + " dog"

#3

Doesn't change the outcome.


#4

Odd. I added the missing a to the phrase and passed. Before adding the a I got an error message saying that sayHello didn't output the correct phrase.


#5

Okay, so adding the a did 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.)


#6

I'm going to shift this topic to the Platform category for the folks upstairs to see. The SCT might need some work.