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 trialMatthew Lehman
5,282 Pointsmy elements are not showing up on my array. May someone please help me
my elements are not showing up on my array.
2 Answers
Bobby Verlaan
29,538 PointsHi Matthew,
You have a typo in your index.html which makes the js scripts were never loaded. Instead of <scipt></scipt> it should be <script></script>. After adding the r to the script tags I tested your code and it worked just fine. Good job!
<script src="js/helpers.js"></script> <!-- added the r to the script tag //-->
<script src="js/playlist.js"></script> <!-- added the r to the script tag //-->
Nejc Vukovic
Full Stack JavaScript Techdegree Graduate 51,574 PointsHi there Matthew Lehman .
I looked at your code:
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);
}
My advice (a bit more DRY):
function printList( list ) {
var listHTML = '<ol>';
for (var i = 0; i < list.length; i += 1) {
listHTML += '<li>' + list[i] + '</li>';
}
listHTML += '</ol>';
document.write(listHTML);
}
You have to be careful -> the print() method is already reserved for JavaScript see here: W3Schools. Not that you can have a problem because of it - you use it window.print() , but just for the future to avoid any unsuspected problems.
And just a little bit of advice: use the Mozilla Developer Network to get explenations about JavaScript stuff and examples of how you can use the methods provide by JavaScript itself.
Try it out and let me know.
Matthew Lehman
5,282 PointsMatthew Lehman
5,282 PointsThanks alot Bobby
I just noticed that error I did right after I submitted the question.
Thanks for catching it before I did.