下面的代码correctSNILS
最终true
在 Firefox(这是正确的)和false
IE7 中。如何识别为什么?
var value = "02324423703";
var correctSNILS = false;
if (value.length == 11) {
var controlDigits = value.slice(9);
var SNILS = value.slice(0, 9);
if (SNILS < 1001998) {
correctSNILS = true;
} else {
var total = SNILS.length;
var result = 0;
for (var i = 0; i < total; i++) {
result += (total - i) * SNILS[i];
}
if (result == 100 || result == 101) result = "00";
if (result > 101) result %= 101;
if (result == controlDigits) correctSNILS = true;
}
}
$("#result").text(correctSNILS);