Function that checks for same numbers in two arrays

Function that checks for same numbers in two arrays
0

#1

I am writing a function that checks for the same number in mulitple arrays. It seems to work when I have an array like [] and [2,4,5] however when I have a two arrays such as [1,2,3,4] and [3,4,5] it doesnt show that 3 and 4 are the matching numbers. Function below.

function intersection(listOne, listTwo) {
  var matches = [];
  for ( var i = 0; i < listOne.length; i++ ) {
    for ( var e = 0; e < listTwo.length; e++ ) {
      if ( a[i] === b[e] ) matches.push( a[i] );
    }
  }
  return matches;
}

Any assistance is appreciated.


#2

A post was merged into an existing topic: Function which checks overlapping numbers


#3

#4