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

Which fix removes the bug?

const emails = rows.map((r) => r.email.toLowerCase());
  1. Guard it: r.email?.toLowerCase() ?? ''
  2. Guard it: r.email!.toLowerCase() ?? ''
  3. Filter the rows after the map call
  4. Change map into a forEach loop
One row without an email throws and kills the whole map; guard the access.
Play Problem Solving ▸