Answers
js:
方法一:
var s1 = "5,0,8";
var s2 = "8,0,5";
if(s1.split(",").sort().join(",") == s2.split(",").sort().join(",")) {
alert("数字相同");
}else{
alert("数字不同");
}
方法二:
var s1 = "5,0,8";
var s2 = "8,0,5";
var a1 = s1.split(",");
var a2 = s2.split(",");
var isSame = false;
if(a1.length == a2.length) {
isSame = true;
var length = a2.length;
for(var i = 0; i < length; i++) {
if(a1.indexOf(a2[i]) < 0) {
isSame = false;
break;
}
}
}
if (isSame) {
alert("数字相同");
}else {
alert("数字不同");
}
zzaaa
answered 12 years, 1 month ago