You are viewing a single comment's thread. Return to all comments →
Solution using JavaScript:
function breakingRecords(scores) { let maxCount = 0; let minCount = 0; let highScore = scores[0]; let lowScore = scores[0];
for(let i = 1; i < scores.length; i++) { if(scores[i] > highScore) { maxCount = maxCount + 1; highScore = scores[i]; } if(scores[i] < lowScore) { minCount = minCount + 1; lowScore = scores[i]; } } return [maxCount, minCount];
}
let scores1 = [3, 4, 21, 36, 10, 28, 35, 5, 24, 42]; console.log(breakingRecords(scores1));
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Breaking the Records
You are viewing a single comment's thread. Return to all comments →
Solution using JavaScript:
function breakingRecords(scores) { let maxCount = 0; let minCount = 0; let highScore = scores[0]; let lowScore = scores[0];
}
let scores1 = [3, 4, 21, 36, 10, 28, 35, 5, 24, 42]; console.log(breakingRecords(scores1));