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 Basics (Retired) Working With Numbers The Random Challenge Solution

B G
B G
1,866 Points

Got a random number but answer is not even close to instructors

I am at a loss. My idea of what he wanted and what I typed in is very different when I watched his video. I don't even understand his answer...

var randomNumGen = prompt('Type number here');

parseInt(randomNumGen + Math.random());

alert(randomNumGen + Math.random());

1 Answer

Andy tran
Andy tran
7,112 Points

Challenge one asks you to generate random numbers from 1 to an input number of a user. For example, if you input 4 into a dialogue box, your program should generate random numbers between 1 and 4, like 1 or 2 or 3 or 4.

Challenge two asks you to generate random numbers in the range between the first input bottom number and the second input top number from a user. If you input number 3 in the dialogue box that pops up the first time for the first bottom number and 6 in the dialogue box that pops up the second time for the second top number, your program should generate random numbers between 3 and 6. The random numbers should be 3, 4, 5 and 6. Each time, it will display 3 or 4 or 5 or 6.