Valid JS-Dev-101 Dumps shared by EduDump.com for Helping Passing JS-Dev-101 Exam! EduDump.com now offer the newest JS-Dev-101 exam dumps, the EduDump.com JS-Dev-101 exam questions have been updated and answers have been corrected get the newest EduDump.com JS-Dev-101 dumps with Test Engine here:
A developer has a fizzbuzz function that, when passed in a number, returns the following: 'fizz' if the number is divisible by 3. 'buzz' if the number is divisible by 5. 'fizzbuzz' if the number is divisible by both 3 and 5. Empty string '' if the number is divisible by neither 3 nor 5. Which two test cases properly test scenarios for the fizzbuzz function?
Correct Answer: A,D
Comprehensive and Detailed Explanation From Exact Extract JavaScript knowledge: First, recall the fizzbuzz rules: If n divisible by 3 and not by 5 → return 'fizz'. If n divisible by 5 and not by 3 → return 'buzz'. If n divisible by both 3 and 5 → return 'fizzbuzz'. Otherwise → return '' (empty string). Evaluate each test: Option A: let res = fizzbuzz(true); console.assert(res === ''); In JavaScript, when using arithmetic operations with true, it is coerced to the number 1. A typical implementation of fizzbuzz would treat the argument as a number and compute: true % 3 → 1 % 3 → 1 true % 5 → 1 % 5 → 1 So true is effectively treated as 1, which is divisible by neither 3 nor 5. The function should return ''. The assertion res === '' will pass. This test covers the scenario "neither divisible by 3 nor 5". Option B: let res = fizzbuzz(3); console.assert(res === ''); 3 is divisible by 3 but not by 5. According to fizzbuzz rules, fizzbuzz(3) should return 'fizz'. This test expects '', so it is incorrect; the assertion would fail in a correct implementation. Option C: let res = fizzbuzz(5); console.assert(res === 'fizz'); 5 is divisible by 5 but not by 3. According to fizzbuzz rules, fizzbuzz(5) should return 'buzz'. This test expects 'fizz', so it is incorrect. Option D: let res = fizzbuzz(15); console.assert(res === 'fizzbuzz'); 15 is divisible by both 3 and 5. According to fizzbuzz rules, fizzbuzz(15) should return 'fizzbuzz'. This assertion correctly matches the expected result, so it is a proper test case. Thus, the two test cases that correctly test valid fizzbuzz behavior are: Study Guide / Concept Reference (no links): Modulo operator (%) for divisibility checks Truthy/number coercion of boolean true in arithmetic (Number(true) === 1) Designing unit tests with console.assert Typical fizzbuzz logic structure and expected outputs ________________________________________