Last active
August 29, 2015 14:06
-
-
Save ravindersahni/1ccd61a3fe981cac4009 to your computer and use it in GitHub Desktop.
Revealing Module FizzBuzz
This file contains hidden or 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
| var totallyEmployable = (function iffy() { | |
| function fizzBuzz(options) { | |
| var isFizz | |
| , isBuzz | |
| , i | |
| options = options || {} | |
| options.low = options.low || 1 | |
| options.high = options.high || 100 | |
| options.fizz = options.fizz || 3 | |
| options.buzz = options.buzz || 5 | |
| for(i = options.low; i <= options.high; ++i) { | |
| isFizz = i % options.fizz === 0 | |
| isBuzz = i % options.buzz === 0 | |
| if (isFizz && isBuzz) { | |
| console.log('FizzBuzz') | |
| } | |
| else if (isFizz) { | |
| console.log('Fizz') | |
| } | |
| else if (isBuzz) { | |
| console.log('Buzz') | |
| } | |
| else { | |
| console.log(i) | |
| } | |
| } | |
| } | |
| return { fizzBuzz : fizzBuzz } | |
| })() | |
| totallyEmployable.fizzBuzz() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment