Skip to content

Instantly share code, notes, and snippets.

@getify getify/fizzbuzz.js
Created Dec 13, 2018

Embed
What would you like to do?
my first ever attempt at fizzbuzz
function fizzbuzz() {
for (let i = 1; i <= 100; i++) {
let div3 = i % 3 == 0;
let div5 = i % 5 == 0;
if (div3 && div5) {
console.log("FizzBuzz");
}
else if (div3) {
console.log("Fizz");
}
else if (div5) {
console.log("Buzz");
}
else {
console.log(i);
}
}
}
@bogas04

This comment has been minimized.

Copy link

commented Dec 13, 2018

Now do it with only one console statement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.