Skip to content

Instantly share code, notes, and snippets.

@Babali42
Forked from edwingustafson/fizzbuzz.js
Created April 3, 2025 22:01
Show Gist options
  • Save Babali42/c7a5981b88909e6b43bad715ef2eec74 to your computer and use it in GitHub Desktop.
Save Babali42/c7a5981b88909e6b43bad715ef2eec74 to your computer and use it in GitHub Desktop.
FizzBuzz is RxJS
#!/usr/bin/env node
const fizz = "Fizz";
const buzz = "Buzz";
const fizzbuzz = `${fizz}${buzz}`;
const Rx = require('rxjs/Rx');
Rx.Observable.range(1,100)
.map(n => n % 15 === 0 ? fizzbuzz : (n % 3 === 0 ? fizz : (n % 5 === 0 ? buzz : n)))
.subscribe(console.log);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment