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 trialKeith Grimes
10,263 PointsList is not stacked, just one long string.
My code seems correct but my list is not stacking in the output. Itβs just one long string as in console output. Why?
const playlist = [
"So What",
"Respect",
"What a Wonderful World",
"At Last",
"Three Little Birds",
"The Way You Look Tonight"
];
const createListItems = (arr) => {
let items = "";
for(let i = 0; i < arr.length; i++) {
items += `<li>${arr[i]}</li>`;
}
return items;
};
document.querySelector("main").innerHTML = `<ol>${playlist}</ol>`;
1 Answer
Steven Parker
231,248 PointsYour interpolation token is inserting the playlist directly (${playlist}
).
But in the video, the token calls the function to process the playlist into list items (${createListItems(playlist)}
).
Keith Grimes
10,263 PointsKeith Grimes
10,263 PointsAh, that did it. Thank you, Steven!