← ⚡ JavaScript World
⚡ FizzBuzz Boss Fight
You can practise without a player, but pick a player to score points!
📖 The mission
Today you unlock
If statements choose a path
An if statement checks a condition and chooses which answer to return. Order matters: check the special cases first.
💡 Hint ladder
- The % operator gives the remainder: 9 % 3 is 0.
- Check the "divides by both" case FIRST, or Fizz will steal it.
- String(n) turns a number into text.
🧪 Coach checks
- ◯ 3 is Fizz
- ◯ 5 is Buzz
- ◯ 15 is FizzBuzz
- ◯ 30 is FizzBuzz
- ◯ 7 stays "7"
- ◯ 1 stays "1"
Live coach
Getting ready
☆☆☆
💬 % gives the remainder after dividing. Remainder 0 means "divides evenly".
function divisibleBy3(n) {
if (n % 3 === 0) {
return "yes";
}
return "no";
}
console.log(divisibleBy3(9)); // yes
console.log(divisibleBy3(10)); // no
📟 It printed:
Nice — you saw it work!
📟 Output
🧩 Gaps filled! Ready to write it all yourself?