Purus Education
JA
Lesson 17

FizzBuzz

Lesson 17 — FizzBuzz (Capstone)

日本語

The final challenge! Write the classic FizzBuzz using everything you've learned — functions, if/elif/else, mod, string interpolation, and loops.

Rules

InputOutput
multiple of 15FizzBuzz
multiple of 3Fizz
multiple of 5Buzz
anything elsethe number itself, e.g. 7

Task

1. Implement fizzbuzz n following the rules. Careful — check the multiple of 15 before 3 and 5!

2. Loop n from 1 to 15 (hint: for n in [1..15]) and print fizzbuzz[n] for each.

Expected output:

1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz

Check

npm test 17

Congratulations!

This was the last lesson. Once your code passes all tests, keep exploring:

Loading editor...
Press Ctrl+Enter to run