Created
February 3, 2023 11:03
-
-
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".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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