Last active
March 13, 2023 10:04
-
-
Save kahunacohen/d67ae91400909681a3ef8069263b58e0 to your computer and use it in GitHub Desktop.
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
/** | |
Fizz buzz in JavaScript: | |
Any number divisible by three, print the word "fizz" and any number divisible | |
by five print the word "buzz". | |
Any number divisible by both three and five print "fizz buzz". | |
*/ | |
for (const n of Array.from(Array(100).keys()).map(n => n + 1)) { | |
if (n % 15 === 0) { | |
console.log("fizz buzz"); | |
} else if(n % 3 === 0) { | |
console.log("fizz"); | |
} else if (n % 5 === 0) { | |
console.log("buzz"); | |
} else { | |
console.log(n); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment