Created
December 13, 2018 18:29
-
-
Save getify/d5705967685c6a9de66b13d4926c6866 to your computer and use it in GitHub Desktop.
my first ever attempt at fizzbuzz
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 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); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now do it with only one console statement