Leetcode Maximum Product Subarray Geeksforgeeks Javascript If Else Statement