• Archive
  • RSS
  • Ask me anything

Daniel Stucke

FizzBuzz CodeYear Fun #schoolstech

With todays announcement from Mr Gove it seems a good point to reflect on my first steps on a year long coding journey. I spent my Tuesday evening completing the first week of lessons on the brilliant CodeYear. It took me about an hour and a half and was a great little introduction to Javascript. First week covers defining variables, basic arithmetic, and moves on to if/then/else/while statements.

It’s an interesting learning model, there are hints at each stage and I didn’t find myself stuck on too many occasions. If you teach ICT or Maths then I’d thoroughly recommend you take a look at it. It was quite a challenge and I’ll be interested to see how far students could get without a teacher to help them. If they do get stuck, some good Googling skills would help them find a way forward pretty quickly. It’s not a replacement for a skilled teacher thought, but that’s a conversation for another post!

The final bonus challenge is to write a FizzBuzz program that writes out a set of consecutive numbers, but replaces multiples of 3 with “Fizz” and multiple of 5 with “Buzz” and of course, multiples of both with “FizzBuzz”. It’s a great little challenge that the Maths teacher in me loved!

I’ve been encouraging staff and students at school to join me on this journey so it’ll be interesting to see how many are up for the challenge.

Here’s my final FizzBuzz code in case you’re interested or stuck:

// Ask user how far we should Fizz Buzz for
var Total = prompt("How far shall we fizz buzz?");

// for the numbers 1 through to Total,
for (i=1; i<=Total; i++) { 

  // if the number is divisible by 3, write "Fizz"
  if ( i % 3 === 0 ) { 
    // unless the number is also divisible by 5, then write "FizzBuzz"
    if ( i % 5 === 0 ) {
    console.log("FizzBuzz");
    }
      else 
        console.log("Fizz");
  }

  // if the number is divisible by 5, write "Buzz"
  else if (i % 5 === 0 ){
    console.log("Buzz");
  }

  // otherwise, write just the number
  else {
    console.log(i);
  }
}

Has anyone written this in a neater, purer way? I’d love to see it if you have.

EDIT:

I have to include this, a solution in a tweet by Martyn Colliver:

    • #Code Academy
    • #codeacademy
    • #coding
    • #programming
    • #ictcurric
    • #ict
    • #maths
    • #Fizz Buzz
    • #codeyear
    • #Javascript
    • #technology
    • #education
    • #teaching
  • 4 months ago
  • 13
  • Comments
  • Permalink
  • Share
    Tweet

13 Notes/ Hide

  1. marthaji02 liked this
  2. emileeyou89 liked this
  3. heatheryi982 liked this
  4. danielstucke posted this

Recent comments

Blog comments powered by Disqus
← Previous • Next →

About

Avatar Assistant Headteacher from Manchester, UK. This is a space for my thoughts on education, technology and more. Has for now taken over from my old blog at www.mrstucke.com

Me, Elsewhere

  • @mrstucke on Twitter
  • SHSELearning on Youtube
  • Mr Stucke on Flickr
  • mrstucke on Delicious
  • danielstucke on Pinboard
  • danielstucke on Last.fm
  • danielstucke on Foursquare
  • Google
  • My Skype Info
  • Linkedin Profile

Twitter

loading tweets…

Following

I Dig These Posts

  • Photo via minimalmac

    Typerighter is a new application that I have been testing for a while. As the developer is a close personal friend of mine and willing to listen...

    Photo via minimalmac
  • Link via parislemon
    Don't Let The Door Hit You On The Way Out Of Google Reader

    Google is ripping out the underlying social stuff in Google Reader — stuff that never...

    Link via parislemon
  • Photo via scienceisbeauty

    This problem! From Calculus By Michael Spivak we suffer on first course. I’ve used it many times and few people are right, even people of...

    Photo via scienceisbeauty
  • Post via willrichardson
    Welcome to My New Space Online

    After 10 years of blogging, I’ve decided to move my efforts away from Weblogg-ed over to here, my new site on Tumblr.

    Post via willrichardson
See more →
  • RSS
  • Random
  • Archive
  • Ask me anything
  • Mobile

Creative Commons License
This work by Daniel Stucke is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
Based on a work at danielstucke.com.. Effector Theme by Carlo Franco.

Powered by Tumblr