$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · easy · #89

Which fix removes the bug?

const name = ' Sara ';
if (name === 'Sara') {
  greet();
}
  1. Compare name.trim() === 'Sara' instead
  2. Compare name.trimAll() === 'Sara' instead
  3. Change === to == in the condition
  4. Wrap the name in String(name) first
The surrounding spaces make the strings differ; trim before comparing.
Play Problem Solving ▸