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 trialLaura Cecil
Courses Plus Student 17,903 PointsWhat's wrong with my code? It runs in Chrome console.
This challenge task 2 of 2 in the Object Literal chapter. The first task was to write the property names to the console. I did that successfully. The second task is to add the property values as well.
The error is Oops! It looks like Task 1 is no longer working - which seems to mean that something in one's code for the next step.
What am I missing? As I said, my code runs fine in the console. Is it some picky way about the way I'm writing out.
var shanghai = {
population: 14.35e6,
longitude: '31.2000 N',
latitude: '121.5000 E',
country: 'CHN'
};
for ( prop in shanghai ) {
console.log (prop, ': ' + shanghai[prop] );
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Objects</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
1 Answer
Mark Wilkowske
Courses Plus Student 18,131 PointsHi Laura, the code challenge validator is being not so much picky as technical. Therefore your answer is flagged for ': ' +
and so the challenge answer is: console.log(prop, shanghai[prop]);
. Some quizes like to hone on what was literally said/taught during the course. I catch myself overthinking at times. Thank God for the forums!