functions to play with commas in js
function removecommas(wordlist) {
for(i=0;i<wordlist.length;i++) {
if (wordlist[i][wordlist[i].length-1] == ',') {
wordlist[i] = popstr(wordlist[i]);
}
}
return wordlist;
}
function hascomma(word) {
if (word[word.length-1] == ',') {
return true;
} else {
return false;
}
}
function checkcommaindex(wordlist) {
var commaslice = [];
var count = 0;
var mode = 'search';
while (count < wordlist.length) {
if (mode == 'search') {
if (hascomma(wordlist[count])) {
commaslice.push(wordlist[count]);
mode = 'slice';
count ++;
} else {
count ++;
}
}
if (mode == 'slice') {
if (hascomma(wordlist[count])) {
commaslice.push(wordlist[count]);
count++;
} else {
mode = 'search';
count++;
}
}
}
return commaslice;
}