= [];
for (var i = start; i < to; i++) {
if (i >= start && i < to) {
ar[ar.length] = this[i];
}
}
return ar.join('');
};
String.prototype.custom_indexOf = function (str_you_find, cursor) {
var at = -1;
var sl = str_you_find.length;
for (var i = cursor; i < this.length - sl; i++) {
var s = [];
for (var j = 0; j < sl; j++) {
s[s.length] = this[i + j];
}
if (s.join('') === str_you_find) {
at = i;
break;
}
}
return at;
};
String.prototype.custom_split = function (spl) {
var arr = [];
var cursor = 0;
for (let i = 0; i < 10; i++) {
var cs = this.custom_indexOf(spl, cursor);
arr[arr.length] = this.custom_slice(cursor, cs == -1 ? this.length : cs);
if (cs === -1) { break; }
cursor = cs + spl.length;
}
return arr;
};
console.log('hello how are you'.custom_split('NONO'));
console.log('hello how are you'.custom_split(' '));
console.log('hello how are you'.custom_split('how'));
It looks like you posted long piece of code, consider editing it out and putting it on hastebin.com and pasting link to it instead. Alternatively, send your code in a file.
Обсуждают сегодня