Leetcode Problem On Array Methods Javascript Map Vs Foreach