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

Which fix removes the bug?

const words = 'red green blue'.split();
console.log(words.length); // expected 3
  1. Use split(',') on it
  2. Pass a space: split(' ')
  3. Call trim() after split
  4. Read words.size instead
With no separator, split returns the whole string as a single element.
Play Problem Solving ▸