Leetcode Problem Reverse An Array Javascript Length Of Object