Click here to Skip to main content
15,880,608 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to generate random numbers in js from specific set of numbers iteratively e.g:

generate random numbers from array of (2,3,4) excluding 1 and next time from (1,3,4) excluding 2 like that. I have used Math.floor and Math.random()but they generate the numbers from given range like(1 to 4). What if i want to exclude any number or want to generate number from given specific set of numbers??
Posted

var randomnumber=Math.floor(Math.random()*11)
 
Share this answer
 
Comments
aeman 30-Dec-12 6:01am    
can u please elaborate how does it work??
Try this

JavaScript
Math.floor((Math.random()*10000)+1);



Thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900