js的数组不区分数据类型,可以存放任意数据类型
<scriptlanguage="javascript" type="text/javascript">
<!--
var weights=[3,5,1,3.4,2,50];
var all_weight=0;
var avg_weight=0;
for(var i=0;i<weights.length;i++){
all_weight+=weights[i];
}
avg_weight=all_weight/weights.length;
document.writeln("总体重是:"+all_weight+""+"平均体重是:"+avg_weight.toFixed(2));
//-->
</script>