var a1=[1,2,3,4,5];
var a2=[2,4,4,2];
alert(isSubset(a1, a2));
function isSubset(a1, a2) {
for (var i = 0; i < a2.length; i++) {
var element = a2[i];
var found = false;
for (var j = 0; j < a1.length; j++) {
if (a1[j] === element) {
found = true;
break;
}
}
if (!found) {
return false;
}
}
return true;
}
|