$ ./guess_the_languageProblem Solving — predict the output
Problem Solving — predict the output · medium · #205

What is the output?

console.log('a-b-c-d'.split('-', 2));
  1. ['a', 'b-c-d']
  2. ['a', 'b', 'c']
  3. ['a', 'b']
  4. ['a-b', 'c-d']
In JavaScript the limit truncates the result array; it does not keep the rest of the string like Python does.
Play Problem Solving ▸