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

Which fix removes the bug?

const ids: number[] = [];
ids.push('7' as unknown as number);
  1. Parse the string first
  2. Widen the array type
  3. Use a const assertion
  4. Declare ids as any[]
The double assertion silences the compiler while leaving a string in a number array.
Play Problem Solving ▸