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

JavaScript JavaScript Arrays Loop Through Arrays Loop Through an Array

do we need to use function to create a " li " to pass in the array?

Do we need to use function to create a " li " to pass in the array so every result will be in a white line?

If there is no function made for the " li ", everything gets stored into 1 line. Is there a way around it?

2 Answers

Steven Parker
Steven Parker
229,920 Points

As used in the video, the list items do more than just make each entry on a separate line, they also affect the foreground and background coloring, and provide item numbers.

But if you only wanted to put the items on different lines, you could put a <br> element after each one.

The way the lists present themselves in the final webpage, is defined by the style.css, which you will see has some code that describes how a list items should behave and appear when viewed in the browser. So by declaring that this lists is full of 'li' items, and passing that to the HTML, you get a neatly defined list, with a visual representation that fits the 'li'-type