Maybe writing all unit tests ahead of time to cover all possible edge cases for a specific function is quite impractical due to time always being against us as software engineers; hopefully, the practice of test-driven development, with the time we can give it, can aid a mindset of considering the full breadth of scenarios for often open-ended problems and their potential solutions.
This is my own educational journey of understanding the how and the why for JavaScript code written to solve common, and often ambiguous, problems. I hope you find my examples helpful as I start to add more.
— @pjnalls
~/test-driven-javascript-dsa (main) $ cd algorithms~/test-driven-javascript-dsa/algorithms (main) $ node fizzbuzz.js$ node fizzbuzz.js
✓ Output is Fizz: 33, Buzz: 20, FizzBuzz: 6 as expected.
✓ Output is Fizz: 0, Buzz: 0, FizzBuzz: 0 as expected.
✓ Output is Fizz: 3, Buzz: 2, FizzBuzz: 0 as expected.
✓ Output is Fizz: 3, Buzz: 1, FizzBuzz: 0 as expected.
✓ Output is Fizz: 1, Buzz: 0, FizzBuzz: 0 as expected.
✓ Output is Fizz: 1, Buzz: 1, FizzBuzz: 0 as expected.
✓ Output is Fizz: 5, Buzz: 3, FizzBuzz: 1 as expected.
✓ Output is Fizz: 33333, Buzz: 19999, FizzBuzz: 6666 as expected.
✓ All tests for 'getNumberOfFizzBuzzWith' solution passed.
$ node fizzbuzz.js
✓ Output is Fizz: 33, Buzz: 20, FizzBuzz: 6 as expected.
✓ Output is Fizz: 0, Buzz: 0, FizzBuzz: 0 as expected.
✓ Output is Fizz: 3, Buzz: 2, FizzBuzz: 0 as expected.
✓ Output is Fizz: 3, Buzz: 1, FizzBuzz: 0 as expected.
✓ Output is Fizz: 1, Buzz: 0, FizzBuzz: 0 as expected.
✓ Output is Fizz: 1, Buzz: 1, FizzBuzz: 0 as expected.
✓ Output is Fizz: 5, Buzz: 3, FizzBuzz: 1 as expected.
✖ Output is Fizz: 3, Buzz: 2, FizzBuzz: 0 but expected Fizz: 33333, Buzz: 19999, FizzBuzz: 6666.
✖ 1 of 8 tests for 'getNumberOfFizzBuzzWith' solution failed.