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

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 27,708 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 27,708 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