compare each 5 numbers of two array [closed]

You could reduce the array by adding the result of compairing the numerical values.

var arrA = ["6", "2", "21", "8", "4", "12"],
    arrB = ["8", "2", "12", "2", "5", "11"],
    count = arrA.reduce((c, v, i) => c + (+v > +arrB[i]), 0);
    
console.log(count);

Leave a Comment