28 - Erro


#1

Na hora compilar o código, da um erro dizendo que não exibe a mensagem esperada, mas está exibindo no console exatamente o que o exercício pede

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

// adicione o metodo sayHello a classe Dog 
// para que todos os cachorros possam dizer alo
Dog.prototype.sayHello = function(){
    console.log("Alô, este é um cachorro [" + this.breed + "]"); 
}

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

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

#2

Unfortunately, I don't know your language :pensive:

Dog.prototype.sayHello = function(){
    console.log("Alô, este é um cachorro [" + this.breed + "]"); 
}

Try to write without ' [ ', ' ] '. Better copy and paste the sentence from instuctions. And you should write ';' in the end. Like in my code:

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

Hope it helped you :wink:


#3

I have tried this, but in my language it's don't allow.
So, I think this exercise is with bug, and I can't fix it.
The console don't accepts this. For this reason, I stoped the leason :smirk:

The console show this message: Parece que seu método sayHello não exibe corretamente no console 'Alo, este eu cachorro [breed]' em que [breed] e a raca do cachorro (Dog)
In english: It seems that your sayHello method does not properly display on the console 'Alo, this I dog' in which [breed] is the dog breed (Dog)


#4

Could you post your updated code?


#5

This exercise in portuguese language...

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

// adicione o metodo sayHello a classe Dog 
// para que todos os cachorros possam dizer alo
Dog.prototype.sayHello = function(){
    console.log("Alô, este é um cachorro " + this.breed);
};

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

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

I tried do it in english, with the code line shown here, but the console don't accepts.


#6

Could you post a link to the exercise in the Portuguese course, please?


#7

https://www.codecademy.com/pt-BR/courses/javascript-beginner-pt-BR-jp4wt/5/2?curriculum_id=5355c2d8516bcbd912000009

Here!


#8

The code you provided;

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

// adicione o metodo sayHello a classe Dog 
// para que todos os cachorros possam dizer alo
Dog.prototype.sayHello = function(){
    console.log("Alô, este é um cachorro " + this.breed);
};

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

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

Passed fine for me. Could you post a screenshot of what you're seeing when you run the code?


#9

I don't understand, now it's done. I don't know what was wrong, but now the code run. I don't modified nothing.
Thanks for your helping.
I appreciate it.


#10

No problem :slight_smile:


#11

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