permutations... in javascript, but a slow algorithm