ballOfSnow, Here's two ways to handle the problem with the array index. My preference is #2.
1. Subtract one from i.
code:
for (i = 0; i < array.length; ++i)
{
if ( /* i must be deleted */ )
{
array.splice(i,1);
--i;
continue;
}
// additional processing on element i here...
}
2. Walk thru the array backwards
code:
for (i = array.length-1; i >= 0; --i)
{
if ( /* i must be deleted */ ) {
array.splice(i,1);
continue;
}
// additional processing on element i here
}




Reply With Quote