This week's book giveaway is in the JavaScript forum. We're giving away four copies of Getting MEAN with Mongo, Express, Angular, and Node and have Simon Holmes on-line! See this thread for details.

OK well i'd just like to say thanks for everybody that replied Random Numbers! But i have one further question...

Lets say I have an array (Array1) of number in any sequence of 1,2,3,4,5,6,7,8,9. Lets say I then have another array (Array2) of numbers between 1 and 9.

How do i make it so that, say, Array1[2] and Array2[2] are not the same i.e. a following situation is avoided?

Do you already have the two arrays, or are you trying to generate the second array? In the first case, you can just test each element. In the second case - well that's a bit more complex. One possibility is to simply generate a second array as you did in your previous problem, then test if there are any duplicates. If there are, simply try again. Repeat until you have a valid second array. This probably isn't very efficient, but it's simple based on what you've already done. Another thing to consider: do you just need to generate a second array, or might you also need to gernate a third, fourth, fifth etc. up to ninth? In this last case you will probably have to be a bit more clever in finding an algorithm...

Thanks Stefan. I get the idea, but what I forgot to mention was that each array had to have the order of numbers randomly generated e.g. 1, 2, 6, 4, 3, 5, 9, 8, 7...