Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

I'm wondering the same thing...


view as:

`console.log` works fine.

What is wrong with this then (not my entry):

    process.stdin.resume();
    process.stdin.setEncoding("ascii");
    process.stdin.on("data", function (input) {
        var output = ''
        if (input % 3 === 0){
            output += 'Fizz'
        }
        if (input % 5 === 0){
            output += 'Buzz'
        }
        console.log(output || input)
    });
Testing locally with

    for(i=1;i<=30;i++){
        process.stdin.emit('data', i.toString())
    }
    process.stdin.destroy()
gives the correct results.

There is no input. You have to print the desired result for all numbers between 1-100

Really? I just wasted 20 minutes trying to figure out whatever that boilerplate was supposed to receive :/

Legal | privacy