Really, pretty much what the title says.
Say you have this string:
var theString = \"a=b=c=d\";
Now, when you run theString
This my implementation:
String.prototype.splitRemainder = function(delim, count) {
if (typeof delim !== 'string') {
return this.split();
}
if (typeof count !== 'number') {
return this.split(delim);
}
if (count < 2) {
return this.split(delim);
}
count--;
const parts = this.split(delim, count);
const remainder = this.slice(parts.join('').length + count);
if (remainder.length > 0) {
parts.push(remainder);
}
return parts;
}
console.log("dasd asds asds asdasd asdasdas".splitRemainder(" ", 4));
console.log("hello-to-you-too".splitRemainder("-",2));
Note that it is not the most efficient way to implement it. So if you're looking for the most efficient solution this is not it.