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 {
_name:name,
get name(){
return this._name
},
set name(newName) {
this.name = newName
},
_breed:breed,
get breed() {
return this._breed
},
set breed (newBreed) {
this.breed = newBreed
},
_weight:weight,
get weight() {
return this._weight
},
set weight(newWeight) {
this.weight = newWeight
},
bark(){
return "ruff! ruff!"
},
eatTooManyTreats() {
this._weight++
}
}
}
const dolf = dogFactory('Dolf','pitbull',10)
console.log(dolf.eatTooManyTreats())