Yeah, I’m also confused about this one.
I followed the first instructions and programmed my setters to only accept string
or number
types, just like in the example lesson they linked too, but the code was rejected and the answer didn’t have any type checking in it.
For example, my code:
set name(newName) {
if (typeof newName === 'string') {
this._name = newName;
} else {
console.log('You must assign a string to name');
Versus their code:
set name(newName) {
this._name = newName;
},
It’s left me a little annoyed, because it kept rejecting my answer even though I tested and got correct returns. I eventually just had it give me the “correct” answer so I could move on.
One final question. Why is it that when you type something like
const dog1 = dogFactory('Fluffy', 'Husky', 15);
you get a return of:

Whereas when you type something like:
const dog1 = dogFactory('Fluffy', 'Husky', 15);
You get a more expected return.

Here’s my code for completeness’ sake:
Long-ish Code Snippet
const dogFactory = (name, breed, weight) => {
return {
// Name Property, Getter, Setter
_name: name,
get name() {
return this._name;
},
set name(newName) {
if (typeof newName === 'string') {
this._name = newName;
} else {
console.log('You must assign a string to name');
}
},
// Breed Property, Getter, Setter
_breed: breed,
get breed() {
return this._breed;
},
set breed(newBreed) {
if (typeof newBreed === 'string') {
this._breed = newBreed;
} else {
console.log('You must assign a string to breed');
}
},
// Weight Property, Getter, Setter
_weight: weight,
get weight () {
return this._weight;
},
set weight(newWeight) {
if (typeof newWeight === 'number') {
this._weight = newWeight;
} else {
console.log('You must assign a number to weight');
}
},
// Dog Methods
bark() {
return 'ruff! ruff!'
},
eatTooManyTreats() {
this._weight++
},
}
};
const dog1 = dogFactory('Fluffy', 'Husky', 15);
console.log(dog1);
console.log(dog1.name, dog1.breed, dog1.weight);
dog1.eatTooManyTreats();
console.log(dog1.weight);
dog1.name = 7;
dog1.breed = 7;
dog1.weight = '';
Thank you for any info you can give.