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

Can't get playList array to print for anything?

I've looked at all the answers for the questions people already posted under this video about this problem but none of their solutions were the issue for me. It simply doesn't work, I don't know why. I tried to snapshot and fork the workspace, but neither of those functions worked so here is my code from workspace

var playList = [];
playList.push('I Did It My Way');
playList.push('Respect', 'Imagine');
playList.unshift('Born to Run');

printList( playList );
function printList( list ) {
  var listHTML = '<ol>';
  for (var i = 0; i < list.length; i += 1) {
    listHTML += '<li>' + list[i] + '</li>';
  }
  listHTML += '</ol>';
  print(listHTML);
}

function print(html) {
  document.write(html);
}
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Musical Playlist</title>
  <link rel="stylesheet" href="css/styles.css">
</head>
<body>
<h1>My Music Playlist</h1>
<div id="listDiv">

</div>
<script scr="js/helpers.js"></script>
<script scr="js/playlist.js"></script>
</body>
</html>

2 Answers

Hi Melissa, Your script scr declarations should be script src. This is causing your JavaScript files to not be loaded. Fix these typos and it will work.

Steven Parker
Steven Parker
243,656 Points

Good catch, Dale. :+1:

I missed that because I loaded the JS directly onto the page to test it, which of course made it work just fine.

Thanks I missed that. Too obvious for me.