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 trialnfs
35,526 PointsThe code is not working as shown in the video. Where am I wrong???
here is my code:
var person = {
name : 'Sarah',
country : 'US',
age : 35,
treehouseStudent : true,
skills : ['JavaScript', 'HTML', 'CSS']
};
for (prop in person) {
console.log(prop, ": ", person[prop]);
}
can anyone please run this exact same code and see where it's wrong??
7 Answers
Alexys Louis
5,260 PointsWhere you have:
for (prop in person) {
console.log(prop, ': ', person[prop]);
}
make sure you're including 'var' before prop.
for (var prop in person) {
}
Hope that helps.
Dario Bahena
10,697 PointsYour code is fine. Reload your browser. Something else is wrong other than your code essentially.
Jennifer Nordell
Treehouse TeacherI'd like to add that it might be a good idea to check some basics. Make sure you've saved the file. If there's an orange dot on the tab, it hasn't been saved. If it has been successfully saved, you might try clearing your browser cache. There's always the chance that it's loading in an older version of your code. Hope this helps!
nfs
35,526 Pointsif you notice it in the console, it's showing this: skills : Array(3);
but in the video, it showed all the skills in the array.... you can review the video {to the last part only, where he opens up the browser console...}
nfs
35,526 PointsThanks, Alexys, you're a lifesaver, can you kindly explain why this works the way it does?
Alexys Louis
5,260 PointsI'm glad I could help.
Remember that 'prop' is a new variable being introduced to the code, so you do have to label it has a variable. I hope that's a good explanation.
Bouh Houssein Kaireh
5,103 PointsThis code is correct check if the error is not come from another part
Bouh Houssein Kaireh
5,103 PointsI recommend to use chrome, it'q better to find the errors