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 2 Solution

page doesn't print objects

students_report.js :

var message = '';
var student;

function print(message) {
  var outputDiv = document.getElementById('output');
  outputDiv.innerHTML = message;
}

for ( var i = 0; i < students.length; i += 1) {
  student = students[i];
  message += '<h2>student: ' + student.name + '</h2>';
}
print(message);

index.html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Students</title>
  <link rel="stylesheet" href="css/styles.css">
</head>
<body>
<h1>Students</h1>
<div id="output">

</div>
  <script src="js/students.js"></script>
  <script src="js/students_report.js"></script>
</body>
</html>

students.js

var students = [ 
  { 
   name: 'Dave',
    track: 'Front End Development',
    achievements: 158,
    points: 14730
  },
  {
    name: 'Jody',
    track: 'iOS Development with Swift',
    achievements: '175',
    points: '16375'
  },
  {
    name: 'Jordan',
    track: 'PHP Development',
    achievements: '55',
    points: '2025'
  },
  {
    name: 'John',
    track: 'Learn WordPress',
    achievements: '40',
    points: '1950'
  },
  {
    name: 'Trish',
    track: 'Rails Development',
    achievements: '5',
    points: '350'
  }
];
rydavim
rydavim
18,814 Points

Can you elaborate on your question? Your code seems to work correctly, printing each student's name to the webpage.

//Fixed Code Presentation

I noticed on chrome the prompt doesn't even show and in IE it does, when I run it on Chrome only the students title is the only thing in the website running

rydavim
rydavim
18,814 Points

Hmm. There doesn't seem to be a prompt in your code. Could you perhaps post a snapshot of your workspace so we can see the latest version? The code posted above doesn't throw any errors for me, and appears to do what I would expect.