For some reason, this course won’t accept the perfectly functional code I submitted. Even when I ask for the solution, the only differences I see are the variables.
My code:
let person = {
_name: 'Lu Xun',
_age: 137,
set age(newAge){
if(typeof newAge === "number"){
this._age = newAge;
}else{
console.log("Invalid input");
return ("Invalid input");
}
}
};
Code that works for some reason:
let person = {
_name: 'Lu Xun',
_age: 137,
set age(ageIn) {
if (typeof ageIn === 'number') {
this._age = ageIn;
}
else {
console.log('Invalid input');
return 'Invalid input';
}
}
};