You are viewing a single comment's thread. Return to all comments →
With Reduce in JS/Javascript:-
function breakingRecords(scores) { const { minScoreCount, maxScoreCount } = scores.reduce((acc, score) => { if (acc.lastMinScore > score) { acc.minScoreCount++; acc.lastMinScore = score; } else if (acc.lastMaxScore < score) { acc.maxScoreCount++; acc.lastMaxScore = score; } return acc; }, { lastMinScore: scores[0], lastMaxScore: scores[0], minScoreCount: 0, maxScoreCount: 0, }); return [maxScoreCount, minScoreCount] }
Seems like cookies are disabled on this browser, please enable them to open this website
Breaking the Records
You are viewing a single comment's thread. Return to all comments →
With Reduce in JS/Javascript:-