Last active
May 11, 2019 00:18
-
-
Save beall49/9b6e734e350b076336b2b6c5cbadfdb1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const fizzBuzz = (start, end) => { | |
const range = [...Array(end).keys()].slice(start, end); | |
range.forEach(indx => { | |
if (indx % 15 === 0) { | |
console.log(`fizzbuzz ${indx}`); | |
} else if (indx % 5 === 0) { | |
console.log(`buzz ${indx}`); | |
} else if (indx % 3 === 0) { | |
console.log(`fizz ${indx}`); | |
} else { | |
console.log(`fail ${indx}`); | |
} | |
}) | |
} | |
const args = process.argv.slice(2); | |
const getArg = (type) => { | |
const ndx = args.indexOf(type) + 1; | |
return parseInt(args[ndx]); | |
} | |
const min = getArg("--start") || 0; | |
const max = getArg('--end') || 1; | |
fizzBuzz(min, max); | |
/* | |
const range = Array.from({ length: (end - start) }, (_, v) => v + start) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment