I have a question about how to compare values inside array.
In particular I read data from an external device and put these data inside an array using:
this.timeArray.push(this.externalDevice)
Now my problem is that I have an array like:
(372) this.timeArray: [Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1),.....]
EDIT: If I expand the array they are like this:
[0 … 99]
0: [20]
1: [40]
2: [60]
3: [80]
4: [100]
5: [120]
6: [140]
7: [160]
8: [180]
Where every values is a number, like 20, 40, 60, .... or -20, -40, -60, ....
Now I have to check that each value is 20 different from the next value.
So for example, if the difference from the second value and the first one is 20, it is correct.
I have tried to used a foreach, but I don't understand how to compare the values, because I have to compare the first with the second value, the second with the third etc.. How can I do?