Can't find cause of my error


#1

In the Learn JavaScript: Objects. Getters and Setters 12/15 I’m receiving the error. “Did you return ‘Invalid input’ inside of an else statement?” I can’t find the issue with my code.

let person = {
_name: ‘Lu Xun’,
_age: 137,

set age(ageIn) {
if (typeof ageIn === ‘number’) {
this._age = ageIn;
} else {
console.log(‘Invalid Input’)
}
}
};


#2

I get the same error on the sample solution as well.


#3

The answer is in the error message.


#4

I, in fact, did try that as well. Like I commented, the error even occurs when the example solution is given. Must be a different problem.


#5

Thanks for the help though mate.


#6

Getters and Setters I

    else {
      console.log('Invalid input');
      return 'Invalid input';
    }

#7


#8

remove line 10: console.log(‘Invalid input’);