Comparing a array
with another array values. I have an array
with a values below.
a = [1,5,6,7,3,8,12];
Below is the array
which i to need to check.
b = [3,5,7];
I have to check whether a
contains
the value of b
.
function contains(n){
for(var i=0; i<this.length; i++){
if(this[i] == n)
return true;
}
return false;
}
a.contains("12"); //would work
a.contains(b) //check for an array values?
The above code works fine when i pass in a number
, can anyone tell me how would i pass an array
and then efficiently compare with another array
.