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 trialIvelina Ventsislavova Stoilova
4,985 PointsAdd a new property -- country -- to newYork. Don't change the original object, just add this new property using a = sign
Iam having difficulty passing this task
var newYork = country {
population: 100,
population: 8.406e6,
latitude: '40.7127 N',
longitude: '74.0059 W',
country: USA
};
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Objects</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
3 Answers
anthony amaro
8,686 Pointshello. remember the way to add keys and values to objetcs
object.keyName = value;
// in this case newYork is the object,
population: 100,
// polutation is the key
// 100 is the value
how would you add another key and value to this object?
newYork.key = 'value';
i hope this makes senses
Steven Parker
231,275 PointsIt looks like you're on task 2, but the first task was "Add a line of code that sets the population property to 8.406e6. Don't change the original declaration of the object."
Remember the warning in the instructions: "Important: In each task of this code challenge, the code you write should be added to the code from the previous task.", so the code you added to pass task 1 should be left as is when you work on task 2.
Then for task 2, it says: "Don't change the original object..." but the code above shows "country" added to the original object. Instead, write a line of code to add it using an assgnment as the instructions asked: "just add this new property using a = sign".
Ivelina Ventsislavova Stoilova
4,985 Pointsthis is how the code from task 1 looks like and it let me pass: var newYork = { population: 100, population: 8.406e6, latitude: '40.7127 N', longitude: '74.0059 W'
}; however now, I still dont get how should I enter the country
Steven Parker
231,275 PointsI guess the checker wasn't being very thorough. Remember the instructions say "Don't change the original declaration of the object."
Both the new population and the country should be added after the object using assigments ("=").