Examples / p5.js Examples / / Fizz Buzz

Fizz Buzz

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

Comments and Questions

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