Skip to content

Instantly share code, notes, and snippets.

@ctjlewis
Last active June 17, 2020 08:02
Show Gist options
  • Save ctjlewis/13f5ca4d4a3f64ff6963f37311fbcd83 to your computer and use it in GitHub Desktop.
Save ctjlewis/13f5ca4d4a3f64ff6963f37311fbcd83 to your computer and use it in GitHub Desktop.
In response to Tom Scott's video at https://www.youtube.com/watch?v=QPZ0pIK_wsc.
// define
const fizzBuzz = (conf, limit) => {
var num = 0;
const check = () => {
for (divisor in conf)
if (num % divisor == 0) return conf[divisor];
return num;
};
while (num++ < limit) console.log(check());
};
// call
fizzBuzz({
3: "fizz",
5: "buzz"
}, 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment