I need to create an algorithm that gives all possible variation of an array. For example.
getVariations([1,2,3]) ;
should return
 [
   [1,2,3],
   [1,3,2],
   [2,1,3],
   [2,3,1],
   [3,1,2],
   [3,2,1]
 ]
I create a fiddle http://jsfiddle.net/rexonms/uf1xot3x/.
 
    