$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · medium · #210

Which fix removes the bug?

function walk(value) {
  if (typeof value === 'array') {
    value.forEach(walk);
  }
}
  1. Test typeof value == 'array'
  2. Test typeof value === 'list'
  3. Use Array.isArray(value)
  4. Use value instanceof Object
typeof returns 'object' for arrays, so the branch never runs.
Play Problem Solving ▸