Message from JavaScript discussions
November 2018
— Yes, correct. we can use a function with param (text, delimeter)
input = ' one two three '
split = (text, delim) ->
a = []
while (b = text.indexOf delim) != -1
a[*] = text.substring 0, b
text = text.substring b + 1
a[*] = text
return a
output = split input, ' '
— Anyone know safari book online?
— Party time🤤
— Https://youtu.be/aeI0vBubajA
—
function tokenize(str, delimiter) {
const tokens = [[]];
for (const char of new String(str)) {
if (char === delimiter) {
if (tokens[tokens.length - 1].length > 0) tokens.push([]);
} else {
tokens[tokens.length - 1].push(char);
}
}
return tokens.map(chars => chars.join(""));
}
— determin1st do you like?
—
tokenize("this is a test string dude bro brotato", " ");
(8) ["this", "is", "a", "test", "string", "dude", "bro", "brotato"]
— determin1st I like that music, this is my style:
https://www.youtube.com/watch?v=aF_RLgHeZcc
— Yes, thank you Floofies for insight about tokenize. With tokenize function.
— No🤤
— Lol