Reverse Array Problem Leetcode Javascript Solution