So let's say I have my first array (arrayOne) with the values of [1,2,3,3,4,2]. I need to compare this array to another array to check for duplicate values (arrayTwo), then display these values.
So, the final output would be: 1, 2, 3, 4.
The catch is I can only use really basic methods, pretty much just booleans, multiple functions, and loops.
How might I go about this? Searching the internet brings up code similar to this:
for (a = 0; a < array1.length; a += 1) {
for (b = 0; b < array2.length; b += 1) {
if (array1[a] !== array2[b])
array2 = array1
}
}
}
output = array2
... so on so forth, but this doesn't seem to work for me (note my code is not exactly like this, but after searching, this seems to be close to what I am looking for).
Any advice?