hi guys,
I am working on a Code Challenges: Intermediate JavaScript and done with my code, but somehow I totally forgot how to check it out (how to log it to the console).
so when I console.log(‘Joe’, ‘Pug’, 27); then Joe Pug 27 prints in the console. But then I don’t understand the purpose of creating getters and setters and adding two additional methods to it, if I don’t use it or don’t know how to check them.
what exactly should I write after it to check it working in the console? Should it be always one part of a code logged or all at the same time? and how am I suppose to check the last two methods as well? thanks!
const dogFactory = (name, breed, weight) => {
return {
_name: name,
_breed: breed,
_weight: weight,
get name() {
return this._name;
},
set name(newName) {
this._name = newName;
},
get breed() {
return this._breed;
},
set breed(newBreed) {
this._breed = newBreed;
},
get weight() {
return this._weight;
},
set weight(newWeight) {
this._weight = newWeight;
},
bark() {
return 'ruff! ruff!'
},
eatTooManyTreats() {
this._weight++
}
}
}