# How to find equal values in an array if they have different index

Hi!
How can we find out if some values in (for example) 2 different arrays, are the same and find them, without getting the help of the index. I mean like if they have different indexes, what should we do?
(This is an example- an exercise from Codecademy course)

let bobsFollowers = [‘Joe’, ‘Marta’, ‘Sam’, ‘Erin’];

let tinasFollowers = [‘Sam’, ‘Marta’, ‘Elle’];

let mutualFollowers = ;

for (let i = 0; i < bobsFollowers.length; i++) {

for (let j = 0; j < tinasFollowers.length; j++) {

if (bobsFollowers[i] === tinasFollowers[j]) {
mutualFollowers.push(bobsFollowers[i]);

}

}
};

We could compare each value of both arrays with each other? So we compare all of them:

``````1 A
1 B
1 C
2 A
2 B
2 C
3 A
3 B
3 C
``````

for which we could nested loops like demonstrated in the code

Doesn’t your code already do that? What are you asking?

Also consider how you’d do it manually, because this is a task you can carry out manually, right? So you’ve already got a solution.

Might be worth mentioning that this can be done in O(N) while what you’re doing costs O(N*N)