var findMaxConsecutiveOnes = function(nums) { let conArr = [], count = 0; nums.forEach((val,index,arr) => { if (val == 1) { count++; } else { conArr.push(count); count = 0; } }); conArr.push(count); return Math.max(...conArr); };