I have to operate a 4 elements array, calculating the difference between the adjacent elements and creating a new array with the resulting differnece. The last element should be colindant with the first one.
example:
firstArray=[0,1,2,3];
secondArray = newArray();
The second array will be:
secondArray[0]: 1-0 = 1
secondArray[1]: 2-1 = 1
secondArray[2]: 3-2 = 1
secondArray[3]: 3-0 = 3
So the new Array should be secondArray=[1,1,1,3]
I tried to do it with a for loop but when the third array is going to be operate it always operate the firstArray[3] - secondArray[0]... when it should be fistArray[3] - firstArray[0]
How can operate the firstArray to differentiate it from the new created secondArray?
Thank you!