Здесь у вас есть:
var a1 = ["cat", "dog", "fish"];
var a2 = ["dog", "monkey", "cat", "horse"];
var matches = 0;
$.each(a1, function(i, a1val){
if($.inArray(a1val, a2)) matches++;
});
var maxn = Math.max(a1.length, a2.length);
var percent = matches/maxn * 100;
alert(parseInt(percent, 10) + "% of similarity");