Permutation Game Hackerrank Javascript Problems