Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Created December 12, 2013 21:09
Show Gist options
  • Save wilmoore/7935485 to your computer and use it in GitHub Desktop.
Save wilmoore/7935485 to your computer and use it in GitHub Desktop.
Unit Testable Fizz Buzz
function isMod0(a, b) {
return a % b === 0;
}
function fb(n) {
var out = '';
if (isMod0(n, 3)) out += 'Fizz';
if (isMod0(n, 5)) out += 'Buzz';
return out;
}
function go() {
idx = 0;
end = 100;
while(++idx <= end) {
console.log(idx, fb(idx));
}
}
exports.fb = fb;
exports.go = go;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment