Jump to content

Problems with a parallel array


stevecjs
 Share

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

Link to comment
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

Link to comment
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

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...