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

idriss Elouilani
PLUS
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

script.js
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>';
index.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JavaScript Objects</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>

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
229,744 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.