Subarray Question On Leetcode Javascript Practice