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 Object-Oriented JavaScript (2015) Constructor Functions and Prototypes Making the UI Work

Help! Uncaught TypeError: Cannot set property 'innerHTML' of null at Playlist.renderInElement (playlist.js:30)

I am having trouble getting the songs to display into the UI. I'm sure I'm missing something small. I've been over the videos 3 times and I cant seem to see what I am doing wrong. Any help would be greatly appreciated. HTML

<!DOCTYPE html>
    <link rel="stylesheet" href="style.css"/>



        <ol id="playlist">
        <button id="play">Play</button>
        <button id="next">Next</button>
        <button id="stop">Stop</button>


    <script src="playlist.js"></script>
    <script src="song.js"></script>
    <script src="app.js"></script>




var playlist = new Playlist();

var hereComesTheSun = new Song("Here Comes the Sun", "The Beatles", "2:54");
var walkingOnSunshine = new Song("Walking on Sunshine", "Katrina and the Waves", "3:43");


var playlistElement = document.getElementById("playList");



function Playlist() {
  this.songs = [];
  this.nowPlayingIndex = 0;

Playlist.prototype.add = function(song) {

Playlist.prototype.play = function() {
  var currentSong = this.songs[this.nowPlayingIndex];

Playlist.prototype.stop = function(){
  var currentSong = this.songs[this.nowPlayingIndex];

Playlist.prototype.next = function() {
  if(this.nowPlayingIndex === this.songs.length){
    this.nowPlayingIndex = 0;

Playlist.prototype.renderInElement = function(list) {
  list.innerHTML = "";
  for(var i = 0; i < this.songs.length; i++){
    list.innerHTML += this.songs[i].toHTML();


function Song(title, artist, duration) {
  this.title = title;
  this.artist = artist;
  this.duration = duration;
  this.isPlaying = false;

Song.prototype.play = function() {
  this.isPlaying = true;

Song.prototype.stop = function() {
  this.isPlaying = false;

Song.prototype.toHTML = function() {
 var htmlString = '<li';
   htmlString += ' class="current"';
 htmlString += '>';
 htmlString += this.title;
 htmlString += ' - ';
 htmlString += this.artist;
 htmlString += '<span class="duration">';
 htmlString += this.duration;
 htmlString += '</span></li>';
 return htmlString;

I just figured it out. Wow, it must be to early in the morning for this, lol!