The preceding carton demo checked the combined case before the individual cases. Apply that branch order to one number at a time in fizzBuzz(number). % returns the remainder, so number % 15 === 0 detects a multiple of both 3 and 5. Use return to send a value back from the function, then log calls in script.js.
Before building FizzBuzz, trace a smaller rule that checks the special case first:
function signal(value) {
if (value % 4 === 0) return "Quad";
return "Ordinary";
}
console.log(signal(8)); // Quad
fizzBuzz(number) to return "FizzBuzz" for multiples of 15, "Fizz" for multiples of 3, "Buzz" for multiples of 5, and the original number otherwise. The provided Ordinary 2 probe should print Ordinary 2: 2.Multiples: Fizz,Buzz,FizzBuzz from calls with 3, 5, and 15.Ordinary 7: 7 from fizzBuzz(7).FizzBuzz on its own line from fizzBuzz(15).Run after each change; the Console should show each requested line on its own.
Start with the smallest function signature, then test one case at a time.