title: Simple Music player for a single (7 track) album (JavaScript Error)
body: <p>So this is my first post requesting for some help. I have dove in the deep end while building my first website by adding a music player to it. I've taken code found online and done my best to tie it into my own. So far most of it is working. The play pause works, previous and back also works. </p>
  
  <p>I think my problem lies within songIndex? When I 'next' after track2 it only goes back to track1. When I try and 'previous' the code shows 'src"undefined"'and no song will play. Not sure if they are related. </p>
  
  <p>Here is the code I belive to be relivant. Any and all help is appreciated. I am only starting off learning Javascript. </p>
  
  <pre><code>songIndex = 0;
  songs = ['/music/track1.mp3',   '/music/track2.mp3',     '/music/track3.mp3',   '/music/track4.mp3',   '/music/track5.mp3',   '/music/track6.mp3',   '/music/track7.mp3'];
  thumbnails = ['/images/J&amp;G Logo.png', '/images/J&amp;G Logo.png', '/images/J&amp;G Logo.png', '/images/J&amp;G Logo.png', '/images/J&amp;G Logo.png', '/images/J&amp;G Logo.png', '/images/J&amp;G Logo.png', ];
  songArtists = ['Jelly &amp; The GOAT', 'Jelly &amp; The GOAT', 'Jelly &amp; The GOAT', 'Jelly &amp; The GOAT', 'Jelly &amp; The GOAT', 'Jelly &amp; The GOAT', 'Jelly &amp; The GOAT',];
  songTitles = ["Track1", "Track2", "Track3", "Track4", "Track5", "Track6", "Track7"];
  </code></pre>
  
  <p>I will skip some lines of code as I don't think they are bugged. </p>
  
  <pre><code>song.addEventListener('ended', function(){
      nextSong();
  });
  
  function nextSong() {
      songIndex++;
      if (songIndex &gt; 1)  {
          songIndex = 0;
      };
      song.src = songs[songIndex];
      thumbnail.src = thumbnails[songIndex];
      background.src = thumbnails[songIndex];
  
      songArtist.innerHTML = songArtists[songIndex];
      songTitle.innerHTML = songTitles[songIndex];
  
      playing = true;
      playPause();
  }
  
  function previousSong() {
      songIndex--;
      if (songIndex &lt; 0)  {
          songIndex = 1;
      };
      song.src = song[songIndex];
      thumbnail.src = thumbnails[songIndex];
      background.src = thumbnails[songIndex];
  
      songArtist.innerHTML = songArtists[songIndex];
      songTitle.innerHTML = songTitles[songIndex];
  
      playing = true;
      playPause();
  }
  </code></pre>
  
  <p>Once again, thanks for any help. One thing I noticed (with the two tracks that are working) if I skip to the next song whilst its playing, the song doesn't auto play and the pause button is still showing (requiring a double click)</p>