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

Which fix removes the bug?

const seen: Map<string, number> = new Map();
seen['a'] = 1;
console.log(seen.size);
  1. Store it with seen.set('a', 1)
  2. Store it with seen.push('a', 1)
  3. Change Map to a plain object type
  4. Read the count with seen.length
Bracket assignment adds a plain property and never touches the Map, so size stays 0.
Play Problem Solving ▸