Tell us what’s happening:
I am using template literals from ES6 to solve this, but it somehow it doesn’t seem to work.
Your code so far
let dog = {
name: "Spot",
numLegs: 4,
sayLegs: () => {return "This dog has ${dog.numLegs} legs." }
};
console.log(dog.sayLegs());
//Output: This dog has ${dog.numLegs} legs.
console.log("This is a dog. His name is ${dog.name}.")
//Output: This is a dog. His name is ${dog.name}.
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/object-oriented-programming/create-a-method-on-an-object