You are viewing a single comment's thread. Return to all comments →
The only advantage is that it also gives the record of each time the record is broken.
function breakingRecords(scores) { var h = [scores[0]]; var l = [scores[0]]; scores.forEach( e=> { if (e>h.reduce((a,c)=>Math.max(a,c))) h.push(e); if (e<l.reduce((a,c)=>Math.min(a,c))) l.push(e); }); return [h.length-1,l.length-1]; }
Breaking the Records
You are viewing a single comment's thread. Return to all comments →
The only advantage is that it also gives the record of each time the record is broken.