Skip to content

Instantly share code, notes, and snippets.

@CodeLeom
Created February 3, 2023 11:03
Show Gist options
  • Save CodeLeom/3a83289256f95b03aaed134615815d4a to your computer and use it in GitHub Desktop.
Save CodeLeom/3a83289256f95b03aaed134615815d4a to your computer and use it in GitHub Desktop.
This Gist solves the question: "Given a list of integers, determine how many of them are divisible by 11. If you encounter an integer in the list that is greater than or equal to 111, return 0 regardless of how many numbers are divisible by 11".
function countDivisibleBy11(list) {
let count = 0;
for (let i = 0; i < list.length; i++) {
if (list[i] >= 111) {
return 0;
}
if (list[i] % 11 === 0) {
count++;
}
}
return count;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment