So I have been racking my brain why this doesn't work, I am sure that I am over thinking it but after googling for a few hours I just can't find it.
So the main thing I am trying is to create a JavaScript function “legs” which takes animal Object and returns some custom message (String) if the animal has 0 legs, 2, 4, and one message for others.
My attempt:
var animal = prompt("Type in an animal")
function legs(animal){
if(animal == 'fish'){
return "no legs";
}else if(animal == 'Tiger'){
return "4 legs";
}else if(animal == 'kangaroo'){
return "2 legs";
}else {
return "I don't know";
}
}
What am I doing wrong?
legsfunction