Fizz Buzz


Fizz Buzz


December 31, 2021

example p5.js javascript if-statements

This sketch plays fizz buzz using the frame count.

  • When the frame count is a multiple of 3, it shows “Fizz”
  • When it’s a multiple of 5, it shows “Buzz”
  • When it’s a multiple of both, it shows “Fizz Buzz”
  • Otherwise, it shows the frame count

Click here to edit this code in the p5.js editor.

Remix Ideas

  • Show different messages instead of fizz and buzz
  • Add other numbers, for example say “boz” when frame count is a multiple of 7
  • Show “fizz” when the number contains a 3, not just when it’s a multiple of 3

If Statements Examples

Comments

Happy Coding is a community of folks just like you learning about coding.
Do you have a comment or question? Post it here!

Comments are powered by the Happy Coding forum. This page has a corresponding forum post, and replies to that post show up as comments here. Click the button above to go to the forum to post a comment!