Created
August 5, 2014 09:04
-
-
Save P1xt/88db3233fd6fbd56b70a to your computer and use it in GitHub Desktop.
Fizz Buzz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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