Shouldn't this be:

```javascript
return [str.substring(0, endpos+1), str.substring(startpos+1, endpos)];
```