Please, somebody help!


#1

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
Use dot notation inside of a console.log() to get the value saved to your _age property and print it to the console.

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
Did you use dot notation to get the value saved to the _age property?


let person = {
  _name: 'Lu Xun',
  _age: 137,
 set age(newage) {
 if (typeof newage ==='number') {
   this._age = newage;}
  else { return 'Invalid input'}
},
get age() {
  console.log(`${this._name} is ${this._age} years old.`);
  return this._age;

}};


person.age='Thirty-nine';
person.age=39;

#2

it seems you use the dot notation to set the age, not getting the age


#3

so what i have to do now?


#4

you already included that in your topic as well:

using console.log() is a good start, given the exercise ask you to log something to the console

lets look at setting a variable:

var exampleVariable = 3

this is what you also do for you age property, however we need to get the value, so to continue on the example we would simply do:

exampleVariable

so no equal sign (which means assign/set variable, or in your case, the equal sign means setting a property)

then we still need to use console.log() to log the value of property to console


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.