Smart Interview Basic Hackerrank Javascript