Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Objects Object Basics Access and Set Object Properties

Addy the pug is now one year older. Add a line of code that sets the age property to 4. Don't change the original declar

Please help me

script.js
const addy = { 
  animal: 'dog',
  age: 3,
  breed: 'pug',
};
age.unit = 4;

2 Answers

Hey Thomas, to access (and therefore read or modify) the value of an object property, you do this:

object.propertyName 

So if you want to change the age property of addy, you would do this:

addy.age = 4;

And it's as simple as that! You can also access an object property's value with bracket notation:

addy['age'] = 4;

I hope this helps!

absolutely no help

So why isn't the following also the correct answer as taught in the lesson? When run in the console it gives the answer of 4.

const addy = { animal: 'dog', age: 3, breed: 'pug' }; const message = Addys age is ${addy.age +1}.; console.log(message);