<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>对比成绩,求和</title>
</head>
<script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
<script type="text/javascript">
$(function() {
var arrResult = new Array(),
sum ='';
function score(arr01, arr02){
sum = 0,arrResult = [];
for(index in arr01){
if(arr01[index] == arr02[index]){
arrResult.push(1);
sum++;
}else{
arrResult.push(0);
}
}
}
//求结果成绩:Ex1
score(['A', 'B', 'C', 'D'], ['A', 'D', 'C', 'B']);
alert(arrResult.join('+') + '=' + sum);
//求结果成绩:Ex2
score(['A', 'B', 'C', 'D'], ['B', 'D', 'C', 'B']);
alert(arrResult.join('+') + '=' + sum);
});
</script>
<div id="test">
</div>
</body>
</html>
loading