Find The Pivot Integer Leetcode Problems Javascript Foreach