[Javascript] I have hit a brick wall

Jonathan Buchanan jonathan.buchanan at gmail.com
Thu Sep 7 10:17:56 CDT 2006


On 9/7/06, Terry Riegel <riegel at clearimageonline.com> wrote:
> Hello,
>
> For some reason I can't seem to get my head around this problem. I
> was able to get a swapImages() function working yesterday to
> basically swap 2 images out. I think my work on that is clouding my
> thinking for the problem before me. Can someone help me with my logic.
>
> I have an array of Objects (actually their ID's) like
>
>
> i[0] = 'imageA'
> i[1] = 'imageB'
> i[2] = 'imageC'
> i[3] = 'imageD'
> i[4] = 'imageE'
> i[5] = 'imageF'
>
> and I would like move imageA to the last position, and ripple all the
> others up. So the result would be...
>
> i[0] = 'imageB'
> i[1] = 'imageC'
> i[2] = 'imageD'
> i[3] = 'imageE'
> i[4] = 'imageF'
> i[5] = 'imageA'
>
> For some reason this seems like a simple problem, but I can't seem to
> come up with the logic for executing it. Any Ideas?
>
> Terry

i.push(i.shift());

Regards,
Jonathan.



More information about the Javascript mailing list