Javascript permutation