Click here to Skip to main content
12,547,806 members (31,755 online)
Rate this:
Please Sign up or sign in to vote.
See more: Javascript

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 29-Dec-12 22:46pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

var randomnumber=Math.floor(Math.random()*11)
aeman 30-Dec-12 6:01am
can u please elaborate how does it work??
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Try this



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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.161021.1 | Last Updated 31 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100