Object Oriented Programming: Create a Method on an Object

Object Oriented Programming: Create a Method on an Object
0

#1

i have been trying to solve the challenge on the link ; https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/object-oriented-programming/create-a-method-on-an-object

but i couldnt …my code so far

let dog = {
name: “Spot”,
numLegs: 4,
sayLegs: function() {return "This dog has " + dog.numLegs + “.”;}
};

dog.sayLegs();


#2

you forgot the very last word ‘legs’


#3

you are the best…i think i need to get a pair of glasses like u…laffs


#4

let dog = {
name: “Spot”,
numLegs: 4,
sayLegs: function() {return "This dog has " + dog.numLegs + "Legs " + “.”;}
};

dog.sayLegs()

Can you explain this then please?


#5

I’m sorry, I have no clue what you are asking me to explain. If you are struggling with this challenge, click on the ‘ask for help’ button and post directly from there (it will include your full code in proper formatting) and you can ask a specific question or describe your issue there.


#6

You have to use lowerCase l in legs and there’s really no reason for you to seperate legs from ..

should be:

"This dog has " + dog.numLegs +" legs."

Make sure you look to the spaces that you include in your strings as well. You should not use space between legs and the .. But you should between dog.numLegs and legs.


#7

Oh, thank you so much,I spent my 10-15 minutes with this.:relieved: