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!
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
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 Parker228,001 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,