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
melissakeith
3,766 PointsCan'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
Dale Severude
Full Stack JavaScript Techdegree Graduate 71,350 PointsHi 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.
melissakeith
3,766 PointsThanks I missed that. Too obvious for me.
Steven Parker
243,656 PointsSteven Parker
243,656 PointsGood catch, Dale.
I missed that because I loaded the JS directly onto the page to test it, which of course made it work just fine.