Hackerrank Javascript Intermediate Solutions