Codecademy Vol. III - The Fizz Buzz Edition

Jack Simpson

Head of Marketing and Communications

So it goes

In another instalment of Codecademy, I took on the challenge of finishing the first course and project.

Rather than trying to squeeze in a few minutes here and there I have taken the block approach, assigning an hour to Codecademy and I flew through the exercises!

Section 6 involved if statements and if/else statements, something that came in more than useful when I took on my first project. Section 7 dealt with incrementors, decrementors and for loops; other useful tools when creating my program. After section 8 which included while loops and do/while loops, I had completed the first course!

Moving on I noticed that the course menu has changed dramatically since my last visit. A whole new branch of online tutorials has been added titled Web including courses such as CSS: Coding with Style and HTML.

The first project is Fizz Buzz. Primarily a group word game often played in primary schools or as a drinking game. Players take turns to count incrementally, replacing any number divisible by three with the word “fizz”, and any number divisible by five with the word “buzz”. This test has also been used as an interview screening device for computer programmers.

Codecademy took me through the process in stages so using my knowledge from the first course it was clear what I needed to do. First I was asked to list all the numbers from 1 to 20 without writing them myself; I was urged to find a ‘more awesome way’. Unsure whether I should use a for loop or a while loop and equally unsure whether it mattered, I settled on a for loop.

In keeping with the Fizz Buzz game the next step was to make every number that is divisible by 3 appear as “Fizz”. With a quick look back at my notes, I used a modulus operator from section 4 and an if statement from section 6. Then by adding an if/else statement I was easily able to make every number that is divisible by 5 appear as “Buzz”. The next step was to make numbers such as 15 that are divisible by 3 and 5 appear as “FizzBuzz” using another if statement.

The final challenge was rather than running the program up to 20, replace the number with a variable to be declared at the beginning of the program. This way, Fizz Buzz solutions for any number can be found. Feeling confident I asked fellow PR Natalie Sneddon to pick a number to try out my program, she chose 15564. I entered the number, nothing happened and then the website stopped responding. I waited it out and eventually … “Fizz”.

Completing my first mini-program has spurred me on to continue using Codecademy to produce bigger and better things. Next on the Javascript menu is Functions but with the introduction of new tutorials, I am going to attempt a HTML course.