Array Based Leetcode Problems Javascript Function Call