Leetcode Problem Reverse An Array Javascript Length