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 Using `for in` to Loop Through an Object's Properties

Isaac Hughes
Isaac Hughes
3,711 Points

skills still shows unavailable in the console

So I added everything that was shown but when the console came up for skills it just showed <unavailable> I can't figure out what the issue is

https://w.trhou.se/a020m66rpz

2 Answers

Your code worked in my console. Maybe try using for(var prop in person)

Robert Stamate
Robert Stamate
13,227 Points

I think you got this right:

var person = {
  name : 'Sarah',
  country : 'US',
  age : 35,
  treehouseStudent : true,
  skills : ['JavaScript', 'HTML', 'CSS']
};

for(prop in person ){
  console.log(prop, ': ', person[prop]);
}

As it works for me in the console too. Tho I would try to get used to the forEach in ES6 as it is a bit more readable in my opinion.

There is also this helpful link: https://www.w3schools.com/js/tryit.asp?filename=tryjs_object_for_in

Kind regards, Robert.