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 trialKord Monaco
3,442 PointsConsole gives me an error at line 14: Cannot read property '0' of undefined at createListItems
const playlist = [
['So What', 'Miles Davis', '9:04']
['Respect', 'Aretha Franklin', '2:45'],
['What a Wonderful World', 'Louis Armstrong', '2:21'],
['At Last', 'Ella Fitzgerald', '4:18'],
['Three Little Birds', 'Bob Marley and the Wailers', '3:01'],
['The Way You Look Tonight', 'Frank Sinatra', '3:21']
];
function createListItems( arr ) {
let items = '';
for ( let i = 0; i < arr.length; i++ ) {
items += `<li>${ arr[i][0] }, by ${ arr[i][1] } - ${ arr[i][2] }</li>`;
}
return items;
}
document.querySelector('main').innerHTML = `
<ol>
${createListItems(playlist)}
</ol>
`;
4 Answers
Kord Monaco
3,442 PointsThank you for the help Cameron! I edited my previous comments to include the correct format for extra practice.
Kord Monaco
3,442 PointsI did not add a comma after the first array, which gave me an error on line 14. Don't you love debugging as a beginner?
const playlist = [
['So What', 'Miles Davis', '9:04'], <---
['Respect', 'Aretha Franklin', '2:45'],
['What a Wonderful World', 'Louis Armstrong', '2:21'],
['At Last', 'Ella Fitzgerald', '4:18'],
['Three Little Birds', 'Bob Marley and the Wailers', '3:01'],
['The Way You Look Tonight', 'Frank Sinatra', '3:21']
];
Cameron Childres
11,817 PointsGlad you got it! That's a way too familiar pain.
Quick tip, use the "markdown cheatsheet" linked under the comment box to format your code next time for easier reading. Like this:
```javascript
code goes here
```
JASON LEE
17,351 PointsI made the same exact mistake in my code!! forgot that comma. ugh.
Giles Lewey
Full Stack JavaScript Techdegree Student 11,347 PointsMe 3! It's because what we cut and pasted from the teacher's notes had an error.
Faraz Malik
20,721 PointsThanks - I had the exact same problem!