Permutation Game Hackerrank Javascript Intermediate