I have 3 arrays named “localCodes”, “standardCodes”, and “specialCodes”. I am trying to confirm if there are any distinct values that appear in all 3 arrays.
What is the most efficient way of going about this?
EDIT:
Below is the code I was playing with, I just feel like there is a simpler way here that I am not getting
Example data set:
localCodes = [1,2,3,4]
standardCodes = [10,2,11,44]
specialCodes = [99,98,89,2]
With that set I would want to return true because 2 is found in each of the 3 arrays.
var longest = localCodes
var longFlag = 'local'
if(standardCodes.length > longest.length){
longest = standardCodes
longFlag = 'standard'
}
if(specialCodes.length > longest.length){
longest = specialCodes
longFlag = 'special'
}
for(l=0; l<longest.length; l++){
if(longFlag == 'local'){
//code here
}
if(longFlag == 'standard'){
//code here
}
if(longFlag == 'special'){
//code here
}
}