代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>for test</title>
<script type="text/javascript">
function testfor(){
//当前系统日期
var a = ['27','28','29','30','31','01','02'];
//当前接口返回值
var b = [
{date:'27',statistics:1},
{date:'27',statistics:2},
{date:'28',statistics:3},
{date:'29',statistics:4},
{date:'29',statistics:5},
{date:'30',statistics:6},
{date:'31',statistics:7}
];
var c = [0,0,0,0,0,0,0];
for(var i=0;i<a.length;i++){
for(var j=0;j<b.length;j++){
if(a[i] == b[j].date){
c[i] = b[j].statistics;
//document.write('a的 '+ i +' b的 ' +j+ '是相等的<br>');
}
}
}
for(var i=0;i<c.length;i++){
document.write(c[i]+'<br>');
}
}
</script>
</head>
<body οnlοad="testfor();">
</body>
</html>