Skip to content

Instantly share code, notes, and snippets.

@jmontross
Forked from rememberlenny/gist:5511395
Created May 3, 2013 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmontross/5513448 to your computer and use it in GitHub Desktop.
Save jmontross/5513448 to your computer and use it in GitHub Desktop.
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