Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save daubattu/ae1b1b064847488db19d832aeb71807c to your computer and use it in GitHub Desktop.
Save daubattu/ae1b1b064847488db19d832aeb71807c to your computer and use it in GitHub Desktop.
[Hackerrank] Solutions of Breaking the Records in JavaScript
function breakingRecords(scores) {
let best = 0;
let worst = 0;
let bestScore = scores[0];
let worstScore = scores[0];
const lengthOfData = scores.length;
for(let i = 1; i < scores.length; i++) {
if (scores[i] > bestScore) {
bestScore = scores[i];
best++;
continue;
}
if (scores[i] < worstScore) {
worstScore = scores[i]
worst++;
continue;
}
}
return [best, worst];
}
@LOML01
Copy link

LOML01 commented Dec 27, 2022

Thanks

@Gwolo-Julius
Copy link

Your code is clean enough! congrats

@EbulfezSadigov
Copy link

in Here dont need to continue

@Mousamia
Copy link

Mousamia commented Feb 1, 2023

Thanks man!
Zajakallahu Khair (may allah give u best return)

@PaulPextra
Copy link

Great job @daubattu 👍 You defined a constant "lengthOfData" but you forgot to use it in your solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment