aboutsummaryrefslogtreecommitdiff
path: root/challenge-001/abigail/node/ch-2.js
blob: daf4abcf8e0ba3c6925a9df5b7b862911a350b57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/local/bin/node

//
// See https://theweeklychallenge.org/blog/perl-weekly-challenge-001
//

//
// Run as: node ch-2.js < input-file
//

  require      ("fs")
. readFileSync (0)               // Read all.
. toString     ()                // Turn it into a string.
. split        ("\n")            // Split on newlines.
. filter       (_ => _ . length) // Filter out empty lines.
. map          (_ => {
    for (let i = 1; i <= +_; i ++) {
        console . log (i % 15 == 0 ? "fizzbuzz"
                     : i %  5 == 0 ?     "buzz"
                     : i %  3 == 0 ? "fizz"
                     : i)
    }
});