P
pantagruel
Hi,
I have an array like the following:
for(x=0;x<results.length;x++){
alert(results.length);
extracted=results.shift();
alert(results.length);
if(results.indexOf(extracted)== -1){
alert(extracted + "was 1")
}else{
alert(extracted + "was more than 1");
alert("here" + results.toString());
alert(results.length);
}
}
with a bunch of results in there. I loop over the results, starting at
8, outputting the number before the shift and the number after the
shift, when I get to the number after the shift = 4 then the indexOf
extracted in the array is obviously not -1 and I get the else, which
tells me that the index of my searchstring was more than 1, and that
the length of my results are 4. Then it stops looping.
This happens when I get to the first instance of a value that is
repeated in the array.
If I do the following
for(x=0;x<=results.length;x++){
alert(results.length);
extracted=results.shift();
alert(results.length);
alert(results.toString());
}
then the same thing happens. the last results toString() I get is
Sonia, me (2),Sonia, me (2),Sonia, me (2),Sonia, me (2)
each Sonia, me (2) is an individual item.
Thanks
I have an array like the following:
for(x=0;x<results.length;x++){
alert(results.length);
extracted=results.shift();
alert(results.length);
if(results.indexOf(extracted)== -1){
alert(extracted + "was 1")
}else{
alert(extracted + "was more than 1");
alert("here" + results.toString());
alert(results.length);
}
}
with a bunch of results in there. I loop over the results, starting at
8, outputting the number before the shift and the number after the
shift, when I get to the number after the shift = 4 then the indexOf
extracted in the array is obviously not -1 and I get the else, which
tells me that the index of my searchstring was more than 1, and that
the length of my results are 4. Then it stops looping.
This happens when I get to the first instance of a value that is
repeated in the array.
If I do the following
for(x=0;x<=results.length;x++){
alert(results.length);
extracted=results.shift();
alert(results.length);
alert(results.toString());
}
then the same thing happens. the last results toString() I get is
Sonia, me (2),Sonia, me (2),Sonia, me (2),Sonia, me (2)
each Sonia, me (2) is an individual item.
Thanks