Jump to content

hew do i specify a start point for a random number

Recommended Posts

For instance i know Math.random() returns a random number between 0 and 1i know Math.floor(Math.random()*11) returns a random # between 0 and 10 but say i wanted the random number to start from 5 and not 0. how do i go about doing this?

Link to post
Share on other sites
var min = 5;var max = 10; Math.floor(Math.random() * (max - min + 1)) + min;


Edited by thescientist
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...