Here's my Fizzbuzz

Can we get this out of the way now?

I've been hearing from my colleagues who are hiring managers now that they've been highly frustrated with the quality of applicants, many of whom can't code their way out of a paperbag. Not even the classic Fizzbuzz test!

We were at a bar when this discussion came up, and in that half-addled state, I quickly scribbled down some pseudocode for it in a few seconds. I got through, and killed off the creeping Impostor Syndrome.

function fizzbuzz(n) {
    for (i = 1; i<=n; i++) {
        if(i%3 === 0) {
            console.log('fizz -- ' + i);
        } 
        if (i%5 === 0) {
            console.log('buzz -- ' + i);
        }
        if ((i%3 === 0) && (i%5 === 0)) {
            console.log('fizzbuzz -- ' + i);
        }
    }
}

fizzbuzz(100);
Show Comments