17 - marching penguins syntax error


#1



I'm getting a syntax error, missing ) after arguments? I can't see a missing ), can anyone spot it?


function Animal(name, numLegs) {
    this.name = name;
    this.numLegs = numLegs;
}
Animal.prototype.sayName = function() {
    console.log("Hi my name is " + this.name);
};


// create a Penguin constructor here
function Penguin(name,numLegs) {
    this.name = name;
    this.numLegs = numLegs;
}

// create a sayName method for Penguins here
Penguin.prototype.sayName = function() {
    console.log("Hi my name is " this.name);
}

// our test code
var theCaptain = new Penguin("Captain Cook", 2);
theCaptain.sayName();


#2

Hi this line

console.log("Hi my name is " this.name);

its missing the + before this.name


#3

Ahh! thank you so much for spotting this


#4

Olá, tente o seguinte, pois funciona:

function Animal(name, numLegs) {
this.name = name;
this.numLegs = numLegs;
}
Animal.prototype.sayName = function() {
console.log("Oi, meu nome é " + this.name);
};

// crie aqui um construtor Penguin
function Penguin(name, numLegs) {
this.name = name;
this.numLegs = numLegs;
}
// crie aqui um metodo sayName para Penguins
Penguin.prototype.sayName = function() {
console.log("Oi, meu nome é " + this.name);
};

// our test cod
var theCaptain = new Penguin("Capitão Cook", 2);
theCaptain.sayName();