Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let string = 'rf||12|asd|13|fkas 55 gg shit pro maskarade ';
- function split(string, separator) {
- let splitContainer = [];
- let currentString = '';
- for (let i = 0; i < string.length + 1; i++) {
- //Get char
- let currentChar = string[i];
- //If separator is encountered or char doesn't exist
- if (currentChar === separator || !currentChar) {
- splitContainer.push(currentString);
- currentString = '';
- continue;
- }
- //Add to filtered string
- currentString += currentChar;
- }
- //Add to array
- return splitContainer;
- }
- let splotString = split(string, '|');
- console.log(splotString);
- //'Real' Split();
- console.log(string.split('|'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement