[Solved] How to compare values of array and if they are equal make them one
[ad_1] You could reduce the array and check if the previous value is equal to the actual value. function sumSame(arrayA, arrayB) { var i, l = arrayA.length, resultA = [], resultB = []; for (i = 0; i < l; i++) { if (arrayA[i] === arrayA[i – 1]) { resultB[resultB.length – 1] += arrayB[i]; } … Read more