Javascript Number Random Scrambler

Posted by stjowa on Stack Overflow See other posts from Stack Overflow or by stjowa
Published on 2010-03-19T16:27:52Z Indexed on 2010/03/19 16:31 UTC
Read the original article Hit count: 248

Filed under:
|
|
|

Hi,

I need a Javascript random number scrambler for my website. Seems simple, but I can not figure out how to do it. Can anyone help me out?

I have the following array of numbers:

1 2 3 4 5 6 7 8 9

I would like to be able to have these numbers scrambled randomly. Like the following:

3 6 4 2 9 5 1 8 7

or

4 1 7 3 5 9 2 6 8

So, specifically, I would like a function that takes in an array of numbers (1 - n) and then returns that same array of numbers - scrambled randomly with different calls to the function.

Maybe a noob function, but can't seem to figure it out.

Thanks!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about algorithm