I have 2 arrays that I need to compare against each other and return the count of the same.
Example: compare array1 [abcd] against array2 [adce]. Return would be 2,1
You get 1 as output because length is not defined in your code
var array1 = ['a','b','c','d'];
var array2 = ['a','d','c','e'];
var length = Math.min(array1.length,array2.length);
var countMatched = 0,countNotMatched = 0;
for(var index=0;index= 0)
countNotMatched++;
}
alert(countMatched );
alert(countNotMatched);
Demo Fiddle : http://jsfiddle.net/tCKE7/2/