Skip to content

Instantly share code, notes, and snippets.

@ravindersahni
Last active August 29, 2015 14:06
Show Gist options
  • Save ravindersahni/1ccd61a3fe981cac4009 to your computer and use it in GitHub Desktop.
Save ravindersahni/1ccd61a3fe981cac4009 to your computer and use it in GitHub Desktop.
Revealing Module FizzBuzz
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