What is the output?
console.log('a-b-c-d'.split('-', 2));
- ['a', 'b-c-d']
- ['a', 'b', 'c']
- ['a', 'b']
- ['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 ▸