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 trialMichael Davis
6,992 Pointsthe console is showing an empty string?
when I check the console in the browser like the teacher does in the video using createListItems(playlist) I get ' ' in return. From the looks of it, I wrote everything correctly.
const playlist = [
'So What',
'Respect',
'What a Wonderful World',
'At Last',
'Three Little Birds',
'The Way You Look Tonight'
];
function createListItems(arr) {
let items ='';
for (let i = 0; i > arr.length; i++ ) {
items += `<li> ${ arr [i] } </li>`;
}
return items;
}
1 Answer
jb30
44,806 PointsThe first time through the for loop, i
is 0
. Since 0 > arr.length
is false, the for loop is done.
Try changing for (let i = 0; i > arr.length; i++ ) {
to for (let i = 0; i < arr.length; i++ ) {
.
Michael Davis
6,992 PointsMichael Davis
6,992 PointsThank you! I can't tell you how dumb I feel. I've been staring at this for about 30 min trying to figure it out and I missed that completely. Sometimes it is the tiniest thing. Thank you again!