$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · hard · #139

Which fix removes the bug?

const copy = { ...settings };
copy.theme.color = 'red';
  1. Clone theme separately too
  2. Use Object.assign instead
  3. Freeze settings beforehand
  4. Spread settings a second time
Spread copies one level, so copy.theme is still the original nested object.
Play Problem Solving ▸