javascript - How to push only the elements not found in my array -
so question asking me remove punctuation word , know how cross-reference tho arrays check if element exists in array checked how push values not in punctuation array?
function removepunctuation(word){ var punctuation = [";", "!", ".", "?", ",", "-"]; var chars = word.split(""); var puncremoved = []; for(var = 0; < chars.length;i++){ for(var j = 0; j < punctuation.length;j++) { if(punctuation[j].indexof(chars[i]) !== 0) { puncremoved.push(i) } } } return puncremoved; }
word.replace(/[;\!\.\?\,-]/g, '');
you might find this interesting :d
Comments
Post a Comment