Skip to content

Instantly share code, notes, and snippets.

@P1xt
Created August 5, 2014 09:04
Show Gist options
  • Save P1xt/88db3233fd6fbd56b70a to your computer and use it in GitHub Desktop.
Save P1xt/88db3233fd6fbd56b70a to your computer and use it in GitHub Desktop.
Fizz Buzz
var fs = require("fs");
fs.readFileSync(process.argv[2]).toString().split('\n').forEach(function (line) {
var myArray = line.split(" "),
output = new Array()
for (var i=1; i<=myArray[2];i++) {
if (i % myArray[0] == 0) {
if (i % myArray[1] == 0) {
output.push("FB")
} else {
output.push("F");
}
} else if (i % myArray[1] ==0) {
output.push("B");
} else {
output.push(i);
}
}
console.log(output.join(" "));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment