Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Dirk Mathu4,050 Points
dumb question (probably)
My generated numbers always display on one long line, even when i put them in a container div on my own created web-page, is this normal for JS? Given that on the video it doesn't seem to be the case, what am i doing wrong?
From what you're describing, it would indicate that you're not concatenating a space between each number.
If the numbers are squished together then the browser treats it as one really long word. By default the browser will not break a long word onto mulitple lines. Instead it will simply overflow its container and you'll get the horizontal scrollbar that you're experiencing.
If the numbers have spaces between them then its treated as multiple words and they will naturally flow to a new line when there's no more space on the current line.
This is what the instructor uses:
document.write(randNum + ' ');
Double check that you have a space between those single quotes. This insures a space will be concatenated after each number.
Steven Parker210,424 Points
Once you put information on a page, it then is displayed using HTML and CSS rules.
For text to show on different lines in an HTML document, it needs more than a new line in the source. There are many ways to accomplish this, and one of the simplest is just to put "
<br>" at the end of each line.
Jonathan Dewitt8,101 Points
Even in the video, the teacher's number outputs are all on one line until they reach the end and then wrap down to a second line. You aren't doing anything wrong and this is normal behavior.
Dirk Mathu4,050 Points
With me the line doesn't end, I have to scroll to the left to see where it ends, and I am talking about 100000 number. Also in the video it seems like the numbers are contained in a division of sorts.
SURENDRA MALLA3,727 Points
document.write(randNum + ", "); may help you see " , " in between the numbers 428, 316, 497, 405, 228, 360, 267, 165, 33, 297,