Creating a method on an object

Can someone take a look at this and tell me why I can’t get my code to properly return sayLegs.

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


I’m guessing that you just need to check the formatting of the message that comes out. Is all the spacing, capitalization, spelling, and punctuation correct?

1 Like

try that

function dog(name, numLegs) { = name,
this.numLegs = numLegs,
this.sayLegs = function () {return 'This dog has '+ this.numLegs + ‘legs.’;};

let spot = new dog(“Spot”, 4);

Your code has been blurred out to avoid spoiling a full working solution for other campers who may not yet want to see a complete solution. In the future, if you post a full passing solution to a challenge and have questions about it, please surround it with [spoiler] and [/spoiler] tags on the line above and below your solution code.

Thank you.