Subarray With Given Sum Hackerrank Javascript