So i have this code that returns the result of comparing 2 arrays. the function compares how many values the two arrays have in common and then outputs the percentage of values that are in common.

```js
const array1 = [1, 2, 3, 7, 1];
const array2 = [1, 3, 6, 7, 6];

const compareThem = (num1, num2) => {
  let finalArray = [];
  num1.forEach((e1) => num2.forEach((e2) => {
    if (e1 === e2) {
      finalArray.push(e1)
    }
  }))
  const divideThem = Math.floor((finalArray.length / num1.length) * 100)
  const toPercent = (divideThem.toFixed(1) + '%')
  return toPercent;

};
console.log(compareThem(array1, array2))
```

But i would like to do something different. I would like to go index by index and have the code say does array1[0] === array2[0], [1] === [1] and so on. I am not looking for total number of values in common rather total number of indices they have in common. I dont want the code to say array1[1] === array2[3].
What would be the best approach to this problem? I am thinking first off i will have to use something other than foreach?