28/30 confused


#1

i have the right output but i get this..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

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" + " "+ this.breed + " "+ "Dog");
}

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

var myDog = new Dog("dachshund");
myDog.sayHello();


#2

Is it because you capitalized Dog when your error hints it should mimic the string which is lower case?


#3

check out your console.log line! too many quotation marks. hope you find to place them right.


#4

YES, it's maddening when I'm trying to learn javascript and I waste an hour because the testing algorithm is dumb and the capitalization of the irrelevant filler text is wrong.


#5

Um, no.
The " "s are to include spaces between the strings and the this.breed.
The problem is like emgo_dev said.


#6

your code should look like this :smile:

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 " + this.breed + " dog");
};

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

var myDog = new Dog("dachshund");
myDog.sayHello();


#7

this one is probably already solved.
I had the same problem and it was a bit confused on how they wanted things to log in the console.
This worked for me : notice one space bar for " dog"

Dog.prototype.sayHello = function() {
    console.log("Hello this is a" + " " + this.breed + " dog"); 
};

To make it logs exactly like
Hello this is a golden retriever dog
Hello this is a dachshund dog


#8

//THIS WORKS
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 "+ this.breed +" dog");
};

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

var myDog = new Dog("dachshund");
myDog.sayHello();


#9

Following up on this, I noticed the following:
Dog.prototype.sayHello = function() {
console.log("Hello, this is a " + this.breed + " dog");
}

The above code logged the correct response in the console, but gave an error.
I changed it to:
Dog.prototype.sayHello = function() {
console.log("Hello, this is a " + [breed] + " dog");
}

And only then did it show it as a success, yet gave an error saying that breed is not defined...


#10

I had this same problem. My "bad code":

Dog.prototype.sayHello = function() {
console.log("Hello this is a " + this.breed + " dog.");
}

Then I removed the dot after dog and it passed.