Let's agree Hackerrank sucks. Develop a shity solution in a very limited time, using ES5 and no libraries for JS, waste time parsing your input where the first element means nothing and the other must have the type converted several times.... If you really want to test a candidate, give them unlimited time, a "real problem" and something that they don't know.
Why something that they don't know? (Actually curious)
The skill that I look for in another developers is the ability to learn stuff that they aren't trained. This way I know that they will be able to solve new problems, to find better solution for old problems. By testing then in something that they don't know, I will see if they are open to learn new stuff and able to apply new concepts, and ask how they felt about it later.