Skip to main content
🟨 JavaScript Foundations

Capstone: FizzBuzz

Time to combine conditionals with the modulo operator. FizzBuzz is a programming rite of passage.

Your task

Write fizzbuzz(n) that returns:

  • "FizzBuzz" if n is divisible by both 3 and 5
  • "Fizz" if divisible by 3
  • "Buzz" if divisible by 5
  • otherwise the number n itself

Order matters β€” check the "both" case first!

⚑ 40 XP

🧱 Code blocks

Drag a block into the editor, or tap it to drop it in where your cursor is. Add them in order to build your answer.

solution.jsRuns in your browser
Loading editor…
Tests4 to pass
3 β†’ Fizz
5 β†’ Buzz
15 β†’ FizzBuzz
1 β†’ 1

Run your code to check these.