-
-
Save jmontross/5513448 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
var FizzBuzz = function(x) | |
{ | |
function isInt(n) { | |
return n % 1 === 0; | |
} | |
function divThree(n) { | |
var nThree = n / 3; | |
return nThree; | |
} | |
function divFive(n) { | |
var nFive = n / 5; | |
return nFive; | |
} | |
var initialize = function init(){ | |
for( var i = 1 ; i < x+1; i++){ | |
if( isInt(divThree(i)) && !isInt(divFive(i)) ){ | |
console.log('Fizz'); | |
}else if( !isInt(divThree(i)) && isInt(divFive(i)) ){ | |
console.log('Buzz'); | |
}else if( isInt(divThree(i)) && isInt(divFive(i)) ){ | |
console.log('FizzBuzz'); | |
} else { | |
console.log(i); | |
} | |
} | |
}; | |
return initialize(); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment