---
title: FizzBuzz: How do you code yours?
layout: post
published: false
---

<p class="lead">Not long ago, I read [http://robertheaton.com/2014/03/07/lessons-from-a-silicon-valley-job-search/](Rob Heaton's article on interviewing in Silicon Valley) with interest, not least because it would be fun to head that way myself one day.</p>


His description of the coding challenges he faced
Read discussion on coders not being able to solve FizzBuzz

Realised I'd never been asked to, nor had I ever considered it.

The problem is as follows:

> Write a program that prints the numbers from 1 to 100. For multiples of three print “Fizz” instead of the number and for multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.”

Here's my JavaScript solution:

{% highlight js %}
for (var i = 1; i <= 100; i++) {
  var string = “”;
  if (i % 3 == 0) {
    string += "Fizz";
  }
  if (i % 5 == 0) {
    string += "Buzz";
  }

  console.log(string || i);
}
{% endhighlight %}

Tempting to over-engineer once you've written first draft. Realise: oh, I could have done this.

How do you FizzBuzz?

http://blog.codinghorror.com/why-cant-programmers-program/
http://imranontech.com/2007/01/24/using-fizzbuzz-to-find-developers-who-grok-coding/

Move fizzbuzz post to drafts
Move fizzbuzz post to drafts
