Difference Between Leetcode Problems Javascript For Loop