Skip to content

Instantly share code, notes, and snippets.

@uknick
Created August 7, 2017 10:14
Show Gist options
  • Save uknick/12799028cc24e11331083498a0e34a8e to your computer and use it in GitHub Desktop.
Save uknick/12799028cc24e11331083498a0e34a8e to your computer and use it in GitHub Desktop.
fizzbuzz
function fizz(i){
var divBy3 = i % 3 === 0;
var divBy5 = i % 5 === 0;
if (divBy3 && divBy5) {
return "fizzBuzz";
} else if (divBy3) {
return "fizz";
} else if (divBy5){
return "buzz";
} else {
return i;
}
}
function fizzLoop(start, end){
for(var i = start; i <= end; i++){
console.log(fizz(i));
}
}
fizzLoop(0,100);
//console.log(fizz(45));
//console.log(fizz(45) === "fizzBuzz");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment