Permutation Game Hackerrank Javascript Basic Certification Solution