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

Natalia Karolinskaya
Natalia Karolinskaya
9,367 Points

I've done it totally differently..

Here is the link (haven't figured out how to insert the snapshot itself in the message)

https://w.trhou.se/x29i6hlqa6

What do you think?

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,253 Points

Hi there Natalia, it looks like you tried but then deleted the snapshop so the link no longer works,

Here's one of my snapshots, https://w.trhou.se/ja0dfp4pk7

You take it by going into one of your workspaces and then you select the one your want from a list of up to 5.

Good luck and i hope we can help you with your problem. :-)

Natalia Karolinskaya
Natalia Karolinskaya
9,367 Points

Yes I 've deleted it! Thanks for pointing out! I'll repost!

1 Answer

damiankomoski
damiankomoski
1,364 Points

Your code isn't appropriate: var generated = Math.floor(Math.random() * number2) + number1;

For example:

In range 0 to 1, you never get number 1.

In range 0 to 3, you never get number 3.

In range 0 to 123, you never get number 123.

In range 0 to 564, you never get number 564.


For range from 0 you have: (INCORRECT)

0 < random <= end

For range from more than 0 you have: (CORRECT)

start < = 'random' < = end


Correct version of this code is: var generated = Math.floor(Math.random() * (number2 - number1 + 1) ) + number1;