16. It's All in the Genes. Can't seem to find my error


#1

I'm not sure what i am doing wrong. I keep getting this error: SyntaxError: missing ) after argument list
here is my code:

// create your Animal class here
function Animal(name,numLegs){
    this.name = name;
    this.numLegs = numLegs;
};


// create the sayName method for Animal
Animal.prototype.sayName = function(x){
    console.log('Hi my name is ' x.name);
};


// provided code to test above constructor and method
var penguin = new Animal("Captain Cook", 2);
penguin.sayName();

#2

wow i just got it

Animal.prototype.sayName = function(x){
    console.log('Hi my name is ' x.name);
};

i missed the "+"

   console.log('Hi my name is ' + x.name);

#3

This does not look quite right. Why the parameter on 'sayName()`?

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

#4

@mtf yeah thanks i put what i had before and it said i could move on though it did have an error in the log box. but i did fix it before i moved on to how you show it.


#5

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