How come the | is not added when I call the join method
var array ="12|23|435|566|46|6|666766|24";
var arraySplit = array.split("|");
var newArray = [];
for (i=0; i<arraySplit.length; i++)
{
if (arraySplit[i] < 500)
{
newArray.push(arraySplit[i]);
}
}
newArray.join("|");
alert(newArray);
newArray.joindoes not modify the existing array. It returns a new string of all the array’s current values, joined by the string you specify. Use the following to store the generated array in a new variable:DEMO: http://jsfiddle.net/EH8dB/
References: