Skip to content

Instantly share code, notes, and snippets.

@getify
Created December 13, 2018 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save getify/d5705967685c6a9de66b13d4926c6866 to your computer and use it in GitHub Desktop.
Save getify/d5705967685c6a9de66b13d4926c6866 to your computer and use it in GitHub Desktop.
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
Copy link

bogas04 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