Question Bank

JavaScript FizzBuzz: Two Implementations Quiz

Difficulty: Medium

Two seeded FizzBuzz implementations (modulo branching and order-sensitive variant) plus two companion drills covering a generalized N-divisors version and a micro-benchmark.

Question Bank
/

JavaScript FizzBuzz: Two Implementations Quiz

JavaScript FizzBuzz: Two Implementations Quiz

Two seeded FizzBuzz implementations (modulo branching and order-sensitive variant) plus two companion drills covering a generalized N-divisors version and a micro-benchmark.

Question Bank
Medium
JavaScript
4 questions
quiz
math
loops
fundamentals

231 views

5

Implement classic FizzBuzz from 1 to n: print fizz for multiples of 3, buzz for multiples of 5, fizzbuzz for multiples of both, otherwise the number. Solve it with explicit modulo branching and the most-specific case first.

Examples

Example 1:

Input: 5
Output: 1, 2, fizz, 4, buzz
Explanation: 3 hits the fizz branch, 5 hits the buzz branch; the rest print as numbers.

Example 2:

Input: 15
Output: ..., fizz, 13, 14, fizzbuzz
Explanation: 15 must print `fizzbuzz` because it is divisible by BOTH 3 and 5; that branch has to come first.