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

Froi Nunez
Froi Nunez
12,133 Points

Javascript Objects, stage 3

It says I should change the population property to a numeric value. I believe I've already done that. Not sure what I've got wrong here. Any suggestions?

script.js
var newYork = {
  population: 100, 
  latitude: '40.7127 N',
  longitude: '74.0059 W'
};

population = 8.406e6;
index.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JavaScript Objects</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>

2 Answers

Hugo Paz
Hugo Paz
15,622 Points

Hi Froi,

You need to change the value of the object population property. You did not select the object. To set an object property you do something like this : object.property = value

your really close! what you need to do is add the population change into the object. use the longitude and latitude as a guide to help you. I hope this helps. look at the comma that is used.

Micole Noddle
Micole Noddle
5,797 Points

I'm stuck on this challenge too. I need a little more help...I think the more I look at it the more I psych myself out! I can't write a code to pass...any additional help would be so greatly appreciated!

Hugo Paz
Hugo Paz
15,622 Points

Hi Micole,

You take the object, choose the property you want to set and assign a value to it.

newYork.population = 8.406e6;
Micole Noddle
Micole Noddle
5,797 Points

Thank you, Hugo! I think I way overthought this one...I kept thinking I had to define it first as a var before I could change it. I really appreciate your help!