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 Loops, Arrays and Objects Simplify Repetitive Tasks with Loops What are Loops?

WHY THIS DOESN'T ADD SPACE BETWEEN NUMBERS!!!!

This is my code function randomNumber(upper) { return Math.floor( Math.random() * upper ) + 1; }

var count = 0; while(count<10){ var value = randomNumber(10); document.write(value + " "); count+=1; } It sometimes doesn't show the output and I'm not able to add space in between values!

1 Answer

Steven Parker
Steven Parker
230,995 Points

There should always be a space between numbers because the code is adding one explicitly. :point_right: value + " "

Note that sometimes the number will be "10" (ten), but there should be a space between it and other numbers.

If you're not seeing consistent results, try restarting your browser or your whole machine. And perhaps try a different browser.