i had finish the code of dogFactory( )function with this code below :
// Write your code here:
const dogFactory = (name, breed, weight) => {
return {
_name:name,
_breed:breed,
_weight:weight,
get name(){
return this._name
},
set name(newName) {
if(typeof newName ==‘string’) {
return this.name = newName
} else {
return ‘please enter type compatible to name’
}
},
get breed() {
return this._breed
},
set breed (newBreed) {
if(typeof newBreed ==‘string’) {
return this.breed = newBreed
} else {
return ‘please enter type compatible to breed’
}
},
get weight() {
return this._weight
},
set weight(newWeight) {
if(typeof newWeight == ‘number’) {
this.weight = newWeight;
}
}
}
}
const dog = dogFactory(10, ‘staff’, 12)
console.log(dog)
but the console return me this output //{ _name: 10,
_breed: ‘staff’,
_weight: 12,
name: [Getter/Setter],
breed: [Getter/Setter],
weight: [Getter/Setter] }
in despite of make a if/else statement the code still return me number when i assign to the property name a number