$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · hard · #116

Which fix removes the bug?

interface Opts { retries?: number }
function run(o: Opts) {
  const r = o.retries || 3;
  return r;
}
  1. Default with o.retries ?? 3 instead
  2. Default with o.retries && 3 instead
  3. Make retries required in the interface
  4. Change the return type to number | undefined
An explicit 0 is falsy and gets replaced by 3; ?? only defaults on null or undefined.
Play Problem Solving ▸