# Problems with a parallel array

## Recommended Posts

Hi allbe kind, i'm new!i have a problem i cant solve;i have 2 arrays, 1 of letters and 1 of numbers.i then have two variables, 1 appears in the letters array and the other appears in the numbers arraywhat i have to do is find the element id of the given letter variable in the letters array and usingthat element id, make the number variable in the number array match by moving the number array alongfor eg; letter array[a,b,c,d]number array[1,2,3,4]letterChar = bnumChar = 4in this example the letterChar resides in element 1 and the numChar lies in element 3i have to move numberArray along (using a function called move() which works fine) so that numchar also lies in element 1i have every other part of this working apart from this part and it's driving me Help!!!!!!RegardsDavid

##### Share on other sites

This sounds suspiciously like homework, so I will keep my advice basic. Put your move() function inside a for-loop or a while loop. End the loop when a certain condition is met.

##### Share on other sites

I should have added: if you can't figure it out, post the most recent code and let the board look at it. Posting the move function is probably a good idea also.

##### Share on other sites

Thank you DDI appreciate your reply, since posting, i have moved a lot further along and now have the skeleton of what i need, i am pleased to find out that i was doing it correctly by using 'for' or 'while'I still can't get the loop to work properly....persistance is key!! many thanks David

##### Share on other sites

Deirdres Dadfor (var counter =0; counter < array.length; counter++){ fred= move(array) fred= move(fred) document.write(fred+ '<br>')}i am trying to get it so that the array of numbers [1,2,3,4,5,6,7,8]output like so; 2,3,4,5,6,7,8,13,4,5,6,7,8,1,24,5,6,7,8,1,2,35,6,7,8,1,2,3,4etc...my move function works fineDavid