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

Which fix removes the bug?

const copy = rows;
copy.length = 0;
console.log(rows.length);
  1. Copy it first with const copy = [...rows]
  2. Copy it first with const copy = {...rows}
  3. Change copy.length = 0 to copy = []
  4. Freeze rows before making the copy
Assignment shares the same array, so clearing the copy clears the original too.
Play Problem Solving ▸