I don't understand this. How do you put the string back together after you have split them? My intention is to sort out the words of 4 letters and under. var mySplitString = myNewString.split(" "); //if(mySplitString[i].length>4){ for (j = 0; j < mySplitString[j].length; j++){ if(j==0){ document.getElementById('keyword0').innerHTML += mySplitString; getKeyURL+=mySplitString; }else{ document.getElementById('keyword0').innerHTML += " " + mySplitString; getKeyURL+=" "+mySplitString; } } Code (markup):
Your loop makes no sense. var text = 'foo bar baz'; var words = text.split(' '); for(var i = 0; i < words.length; i++) { // in this context, .length is the number of elements within an array // words[i] is the current word, do something with it if(words[i].length < 4) { // in this context, .length is the character count of a string // short word... } else { // longer word... document.getElementById('keyword0').innerHTML += mySplitString + ' '; } } Code (markup):
To join pieces of array into string: var string=array.join([ separator])//separator is optional Code (markup):
rohan_shenoy, didn't you read his request? He needs to filter out certain entries from his array, not join them all together.