please can someone help me what i do wrong in the last step when i had create a eatTooManyTreats function when i try to run this function by call it like this : const dolf = dogFactory(‘Dolf’,‘pitbull’,10)
console.log(dolf.eatTooManyTreats()) it run me “undefined” please can someone help me to fix it and this my code below :

// Write your code here:
const dogFactory = (name, breed, weight) => {
 return {
      get name(){
   return this._name
 set name(newName) { = newName
    get breed() {
     return this._breed
   set breed (newBreed) {
    this.breed = newBreed
  get weight() {
       return this._weight
     set weight(newWeight) {
     this.weight = newWeight
       return "ruff! ruff!"
     eatTooManyTreats() {
const dolf = dogFactory('Dolf','pitbull',10)


Your eatTooManyTreats() function doesn’t really return anything, it’s just assigning a new value to the weight attribute of your object.

When you do this:

You are basically trying to log whatever value that call to the function returns, but since it doesn’t return anything, undefined is logged to the console.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.