Skip to content

Instantly share code, notes, and snippets.

@usagi
Created February 20, 2012 15:15
Show Gist options
  • Select an option

  • Save usagi/1869620 to your computer and use it in GitHub Desktop.

Select an option

Save usagi/1869620 to your computer and use it in GitHub Desktop.
const number_of_begin = 1;
const number_of_end = 20;
const word_of_fizz = "Fizz";
const word_of_buzz = "Buzz";
function fizz(n){ return n % 3 == 0; }
function buzz(n){ return n % 5 == 0; }
for(var n=number_of_begin;n<=number_of_end;++n){
var is_fizz = fizz(n);
var is_buzz = buzz(n);
if(is_fizz) console.log(word_of_fizz);
if(is_buzz) console.log(word_of_buzz);
else if(!is_fizz) console.log(n);
// for debug
console.log("debug log:",n,is_fizz,fizz(n),is_buzz,buzz(n));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment