Last active
April 3, 2025 22:04
-
-
Save edwingustafson/dc8199bd4dec09df03243422b960d467 to your computer and use it in GitHub Desktop.
FizzBuzz is RxJS
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
#!/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
I really like it !
A new way with rxJs 6 or. above could be