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

Clean console but nothing printing to web page.

Having a hard time understanding why nothing is displaying.

let students = [
  {
    name: `Francis`,
    track: `FEWD`,
    acheivements: 58,
    points: 987,
  },
  {
    name: `Hermon`,
    track: `JavaScript`,
    acheivements: 34,
    points: 234,
  },
  {
    name: `Banana`,
    track: `Python`,
    acheivements: 324,
    points: 23,
  },
  {
    name: `Jesse`,
    track: `Ruby`,
    acheivements: 234,
    points: 3434,
  },
  {
    name: `Adam`,
    track: `Scala`,
    acheivements: 324234,
    points: 4322342,
  }

];

function print(message) {
  let output = document.getElementById(`output`);
  output.inerHTML = message;
}

function buildList() {
  let list = ``;
  for (let i = 0; i < students.length; i++) { 
    list += `<ul>`;
    list += `<li><strong>${students[i].name}</strong></li>`;
    list += `<li>${students[i].track}</li>`;
    list += `<li>${students[i].acheivements}</li>`;
    list += `<li>${students[i].points}</li>`;
    list += `</ul>`;
  }
  return list;
}


print(buildList());

Any help appreciated, thanks!

3 Answers

Rich Donnellan
MOD
Rich Donnellan
Treehouse Moderator 25,764 Points

Typo.

- output.inerHTML = message;
+ output.innerHTML = message;
Grzegorz Zielinski
Grzegorz Zielinski
5,838 Points

Hello :)

You've made a spelling mistake in this bit of code:

function print(message) {
  let output = document.getElementById(`output`);
  output.inerHTML = message;
}

To be precised - it should be "innerHTML", not "inerHTML".

I hope it helps!

Thank you so much, wonderful people!

Rich Donnellan
Rich Donnellan
Treehouse Moderator 25,764 Points

No problem.

FYI — I debugged by pasting your code right into Chrome's Dev Tools console. It came back with this error which was easy to pinpoint the mistake:

VM4561:37 Uncaught TypeError: Cannot set property 'inerHTML' of null
    at print (<anonymous>:37:19)
    at <anonymous>:54:1