Javascript Number Random Shuffle
- by stjowa
Hi,
I need a Javascript random number shuffler 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 shuffled 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 - shuffled randomly with different calls to the function.
Maybe a noob function, but can't seem to figure it out.
Thanks!
NOTE: Thanks for the clarification on "Shuffle". Have found a lot more online about this with that term.