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

Ryan Soeder
Ryan Soeder
7,155 Points

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,701 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!

Ryan Soeder
Ryan Soeder
7,155 Points

Thank you so much, wonderful people!

Rich Donnellan
Rich Donnellan
Treehouse Moderator 25,701 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