Its All in the genes mess


#1

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

// create the sayName method for Animal
Animal.prototype.sayName = function() {
console.log("Hi, my name is" + " " + this.name);
}

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

SyntaxError: missing ( before formal parameters

Am i blind?? i refreshed the browser 30 times but ......


#2

function Animal = function(name, numLegs) {

That's not right. Go find an example to compare to.


#3

the code was ok
exactly the same i copied and pasted i dont know why it worked with a copy paste method
and i continue using function Animal = function(name, numLegs) {};
thank you for replying and i am sorry for my bad english. i just solved it;


#4

That's invalid syntax. It's wrong. Your JS interpreter will refuse to run that code.

If anything is telling you that's right, then that something is also wrong.


#5

function Animal(parameter1, parameter2) {}; i pasted wrong code.
you are totally right. it would be better if you told me the right code not only telling me that is wrong. of course is wrong. Thank you!


#6

I'm much more interested in helping you along in finding the mistake and fixing it than just giving you the correct code. Being able to fix mistakes is far more valuable than knowing how a single thing should look like. We make mistakes, so we need to be good at fixing them.

If that part was obviously wrong, then you should have included that in the question, to show that you had figured out as much. That would also tell you what to look for, which is examples on the internet for how a function header should look like.