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 trialBjörn Wauben
10,748 PointsAdding properties to an Object
The challenge is: "Add three properties to this object: population with a value of 2.211e6 (that's 2.211 million using exponential notation), a latitude property with a value of '48.8567 N', and a longitude property with a value of '2.3508 E'."
My code keeps bringing up a syntaxError. I can't see what's wrong. Are these al numbers? I thought the second and third one are supposed to be strings? Seems really silly I can't pass a challenge where I just need to type three properties in an Object.
var paris {
population = 2.211e6,
latitude = '48.8567 N',
longitude = '2.3508 E'
};
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Objects</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
10 Answers
Jonathan Grieve
Treehouse Moderator 91,253 PointsHi there Bjorn,
You can also try
var paris {
population: 2.211e6,
latitude: 48.8567 N,
longitude: 2.3508 E
};
The 2 main things I noticed were that Object properties are part of a structure of keys and associated values.
Also number values are not enclosed in quotes. :-)
Try this and it should pass too.
Tim Imasa
8,816 PointsHello Jonathan,
I tried your code above, it says:
SyntaxError: Parse Error
Any ideas?
EDIT:
I passed the challenge by entering this code:
var paris = {
population = 2.211e6,
latitude = '48.8567 N',
longitude = '2.3508 E'
};
Jonathan Grieve
Treehouse Moderator 91,253 PointsIt must be due to the N and the E in the code, which I didn't pick up on. Ooops!
I but if this is an object, I can't see why assigning them with = works. An object is a structure of keys and the values.
This code will pass
var paris = {
population: 2.211e6,
latitude: '48.8567 N',
longitude:'2.3508 E'
};
but this won't.
var paris = {
population: 2.211e6,
latitude: '48.8567 N',
longitude:'2.3508 E'
};
Baheejah Fareed
3,450 PointsThe challenge wouldn't accept N or E from me. It worked after I wrote the code that you have, but without the N and E.
Josephine Mukuya
5,911 Pointsthis passed for me,,
var paris = { population: 2.211e6, latitude: 48.8567, longitude: 2.3508
};
Michael Oxborrow
7,186 PointsI think there is a bug in this question. Same thing happened to me. Correct code not passing.
Miriam Rozenbaum
3,671 PointsThey do not want you to use the 2.211e6. (Maybe its there to just confuse) Use the other number provided for the population. (that's 2.211 million using exponential notation)
var paris = { population : 2.211, latitude : '48.8567 N', longitude : '2.3508 E'
};
sharmile thaneshkumar
3,003 PointsThis work for me.
var paris = { population: 2.211e6, latitude:'48.8567 N', longitude: '2.3508 E' };
Emmet Lowry
10,196 PointsIts very odd.
Motuma Kaba
11,960 PointsThis code worked for me
var paris = { population: 2.211e6, latitude:'48.8567 N', longitude: '2.3508 E' };
Douglas Christman
10,045 PointsSame here. I kept getting an error that it couldn't find the properties population, longitude and latitude, even though they were clearly defined. I had to reset the code several times for it to work.
Sihyun Pratt
6,010 Pointsvar paris = { population : “2.211e6”, latitude : “48.8567 N”, longitude : “2.3508 E” };
Sihyun Pratt
6,010 PointsIt's pretty important to put quotation marks around the strings.
Unsubscribed User
Full Stack JavaScript Techdegree Student 3,355 PointsWhy does the code must take quotation marks ' ' for the last two properties? I know they are coordinates but why?
var paris = { population: 2.211e6, latitude: '48.8567 N', longitude: '2.3508 E'
};
Björn Wauben
10,748 PointsBjörn Wauben
10,748 PointsI found the problem on my own. Somehow in the editor of the challenge my properties turned "blue" instead of "green" inside the object. I copied a similar Object from a later challenge and edited the numbers to pass this particular challenge. Now it passed. Strange.