Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Loops, Arrays and Objects Tracking Data Using Objects The Build an Object Challenge, Part 2

Jaime Aguilar
Jaime Aguilar
7,651 Points

How to get the first line of each object in bold?

 function print(message){
var question;
var students = [
  { Name:"Jaime",
    Track:"Full-Stack JavaScript",
    Achievements: 12,
    Points: 1404
      Achievements: 50,
      Points: 7414
      Track:"Java Web Developent",
      Achievements: 2,
      Points: 304
      Achievements: 1,
      Points: 50
      Track:"Full-Stack JavaScript",
      Achievements: 78,
      Points: 15081
//for loop cycles though all items in the array
// for in loop cycles though all objects
//key represents each object {} name (ex) name:, track:
// students[i][key] prints out everything in that object: ex things in quotes
for(var i = 0; i<students.length; i+=1){
  for(var key in students[i]){
    print("<li><B>" + key + ": " +"</B>" + students[i][key] +  "</li>"+"");
  print("------------------" + "<br>")

This is what i have so far, not sure how else to style it to show where one object ends and the other begins.

1 Answer

Steven Parker
Steven Parker
216,891 Points

First, it looks like you're missing the opening tags for your lists. The first line of the outer loop should probably be:


Then, since you're inner loop works by key, you'd need some extra code to determine which one is first. Perhaps a boolean that is set in the outer loop and cleared once the first item has been printed?

But it's also something that can easily be done just with CSS:

li:first-child { font-weight: bold; }