Created
October 25, 2017 17:24
-
-
Save elevenpassin/8f92e5249f765484f489095775474cdc 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
/* | |
A program that prints all the numbers from 1 to 100, with two exceptions. | |
For numbers divisible by 3, it prints "Fizz" instead of the number, and for numbers divisible by 5 (and not 3), it prints "Buzz" instead. | |
For numbers divisible by both 3 & 5, it prints "FizzBuzz". | |
TODO: | |
- Can we make this more progressive/dynamic in any ways? | |
*/ | |
function fizzBuzz(){ | |
for(var i=1; i <= 100; i++){ | |
if (i % 3 === 0 && i % 5 === 0) { | |
console.log("FizzBuzz"); | |
} else if (i % 3 === 0) { | |
console.log("Fizz"); | |
} else if (i % 5 === 0) { | |
console.log("Buzz"); | |
} else { | |
console.log(i); | |
} | |
} | |
} | |
module.exports = { | |
fizzBuzz : 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
/* | |
A program that prints all the numbers from 1 to 100, with two exceptions. | |
For numbers divisible by 3, it prints "Fizz" instead of the number, and for numbers divisible by 5 (and not 3), it prints "Buzz" instead. | |
For numbers divisible by both 3 & 5, it prints "FizzBuzz". | |
TODO: | |
- Can we make this more progressive/dynamic in any ways? | |
*/ | |
function fizzBuzz(){ | |
for(var i=1; i <= 100; i++){ | |
if (i % 3 === 0 && i % 5 === 0) { | |
console.log("FizzBuzz"); | |
} else if (i % 3 === 0) { | |
console.log("Fizz"); | |
} else if (i % 5 === 0) { | |
console.log("Buzz"); | |
} else { | |
console.log(i); | |
} | |
} | |
} | |
module.exports = { | |
fizzBuzz : fizzBuzz | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment