标签:isnan text func i++ write cti while function utf-8
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<script type="text/javascript">
function sum(m,n){
if(isNaN(m)||isNaN(n)) return NaN; //判断参数是否是合法数字
if(m>n)return 0;
var result=0;
var i=m;
do{
if(i%2==0)//判断这个数字是否是偶数
{
result+=i;
}
i++;
}while(i<=n);
return result;
}
(function(){
document.write("计算出3--200之间的偶数和:"+sum(3,200));
})();
</script>
<body>
</body>
</html>
标签:isnan text func i++ write cti while function utf-8
原文地址:http://www.cnblogs.com/wxhhts/p/7755669.html