Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Loops, Arrays and Objects Tracking Data Using Objects Access and Set Object Properties

idriss Elouilani
idriss Elouilani
Courses Plus Student 1,232 Points

country to newYork but I got to second part it doesn't work. I got the message task number one is no longer passing

I tried to add country which USA to newYork but the second doesn't work. I got the message that task number 1 is no longer working

var newYork = {
  population: 100, 
  latitude: '40.7127 N',
  longitude: '74.0059 W'
newYork.population = 8.406e6;
message = '<p>newYork' + newYork.population + '</p>';
newYork.country = USA;
message = '<p>newYork' + newYork.country + '</P>';
<!DOCTYPE html>
  <meta charset="utf-8">
  <title>JavaScript Objects</title>
<script src="script.js"></script>

5 Answers

Hi there,

clarified this a bit, was a little vague

You're close - when you get a previous task error, you should check your syntax first. If you're not sure, you can always go back to the first task and run the code - sometimes it will give you a more detailed error from there. The error it gives with this code is a good clue. It says it can't find a variable called "USA" - that means that something about USA isn't right. It is giving the error there because "USA" is a string value - it needs to have quotes around it, otherwise it's going to look for a variable called USA, which doesn't exist. So, that line should look like:

newYork.country = "USA";

On the next line, the 'p' in the closing paragraph tag needs to be lowercase as well. You don't need the message, but having it there won't affect the challenge.

That should be it!

Steven Parker
Steven Parker
216,688 Points

The challenge always rechecks tasks in order, so any syntax error invalidates the entire script and causes it to interpret it as task 1 not passing.

In this case the cause is a reference to an undefined variable named USA. I'm pretty sure that is intended to be a string so it should be "USA" in quotes.

Also, you don't need to set a "message" variable, that's not in the challenge instructions so you can remove both of those lines.