Minimum Array End Leetcode Javascript Problems