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 Loops, Arrays and Objects Tracking Data Using Objects Access and Set Object Properties

Raeed Sabree
Raeed Sabree
10,664 Points

dd a new property -- country -- to newYork. Don't change the original object, just add this new property using a = sign

how do i do that?

var newYork = {
  population: 100, 
  latitude: '40.7127 N',
  longitude: '74.0059 W'

newYork.population = 8.406e6
<!DOCTYPE html>
  <meta charset="utf-8">
  <title>JavaScript Objects</title>
<script src="script.js"></script>
Simon Coates
Simon Coates
28,694 Points

why'd you post this to the forum? Your answer passes the challenge. (update: sorry wrong challenge, Dale Severude is right)

2 Answers

Dale Severude
.a{fill-rule:evenodd;}techdegree seal-36
Dale Severude
Full Stack JavaScript Techdegree Graduate 71,349 Points

Same way as the one you just did, just add a period and assign the value with an equals sign.

newYork.population = 8.406e6;
newYork.country = 'USA';

Great job solving the first task! :thumbsup: To add a new property, you could do this: (This won't work in the challenge; it is for showing you how you could solve the challenge)

var person = {
    name: "Raeed Sabree",
    age: 30,

person.eyeColor = "brown";

Hope this gives you an idea of how you could solve the task! :dizzy: