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 The Build an Object Challenge, Part 1 Solution

Ronnelle Torres
Ronnelle Torres
5,958 Points

THIS IS WHAT I DID IN PART 1.

function print (message, element) {
 var HTML = document.getElementById(element);
  HTML.innerHTML= message;
}
function list (name, track, achievements, points) {
  return "<li>"+ name
        + "<ul>"
           + "<li>"+ track.join(", ") + "</li>"
           + "<li>" + achievements + "</li>"
           + "<li>" + points + "</li>"
      + "</ul></li>"
}
var insideHTML= "<ol>";
var students = [
  {name:'ron', track:['html', 'css', 'javascript'], achievements:3000, points:3100 },
    {name:'grace', track:['design', 'photoshop', 'html'], achievements:2000, points:2100 },
    {name:'mae', track:['c#', 'python', 'php'], achievements:1000, points:1100 },
    {name:'nel', track:['javascript', 'python', 'design'], achievements:4000, points:100 },
    {name:'boom', track:['javascript', 'c#', 'android'], achievements:4000, points:100 }
];


for (i=0; students.length > i; i++) {
    insideHTML+=list(students[i].name, students[i].track, students[i].achievements, students[i].points);
}
insideHTML+="</ol>"
print(insideHTML, "output");
Steven Parker
Steven Parker
231,269 Points

And do you have a question or problem?

4 Answers

Tommy Gebru
Tommy Gebru
30,164 Points

I can only recommend quitting your job if it alleviates the burden of learning, also if your learning environment is positive and reinforces learning then it is a great choice to do so....

Tommy Gebru
Tommy Gebru
30,164 Points

Hey Ronnelle,

Please provide more information when posting to the forum

:thumbsup:

Ronnelle Torres
Ronnelle Torres
5,958 Points

Oh I apologize. My question is, how can I print the property? In this code I have only printed the value. I was hoping to get this format printed. Please help, thanks! :D

Name: ron Track: javascipt , etc.

Aaron Martone
Aaron Martone
3,290 Points

I assume this code comes with some html like: <div id="output"></div>, right? Are you attempting to send the output to a printer? You can use window.print(); but I don't think it accepts arguments. It prints what was output to the document. If you want to just view the variable, you can use: console.log(innerHTML);

Tommy Gebru
Tommy Gebru
30,164 Points

Were you able to pass the challenge?

Ronnelle Torres
Ronnelle Torres
5,958 Points

Yes I did! :D The part 2 was a bit challenging.. Though thankfully I was able to do it without peaking on the solution video. hahah. Now I'm on the third challenge, the search thingy. I hope I can do it. It's hard to work at the same time study. I'm planning to quit my job so that I can study more.. Do you think it's a wise decision? Thanks for the advice! :)