Partition Array Into Two Parts Leetcode Javascript Question