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 trialRodrigo Bahiense
8,211 PointsI solved using function
That's the way I solved the exercise. Is it correct?
function randomNumber() { var num = Math.floor(Math.random() * 9); return num; }
do { i = randomNumber(); text += i + ' ';
} while (i != 8);
2 Answers
Steven Parker
231,275 PointsSince the "random" function always returns a value below 1, the multiplier must always be more than the highest value you want to see.
So to generate numbers from 0 to 9, you must multiply by 10 (instead of 9).
Rodrigo Bahiense
8,211 PointsThank you!