Minimum Array End Leetcode Problems Javascript