恢復內容開始 恢復內容結束 ...
---恢復內容開始---
let values = [];//數組(整型數字)
//獲取數組最大值
function arrMaxNum(arr){
var maxNum = null;
for (var i = 0; i < arr.length; i++) {
var item =parseInt(arr[i]);
if(item){
if(!maxNum){
maxNum = item;
}
item>maxNum ? maxNum =item : null;
}
};
return maxNum;
};
//獲取數組最小值(排除0)
function arrMinNum(arr){
var minNum = null;
for (var i = 0; i < arr.length; i++) {
var item =parseInt(arr[i]);
if(item){
if(!minNum){
minNum = item;
}
item<minNum ? minNum =item : null;
}
};
return minNum;
};
//獲取數組平均值(排除0)
function arrAverageNum(arr){
var sum = 0;
var count = 0
for (var i = 0; i < arr.length; i++) {
var item =parseInt(arr[i]);
if(item){
sum += item;
count++;
}
};
return ~~(sum/count*100)/100;
};
---恢復內容結束---
let values = [];//數組(整型數字)
//獲取數組最大值
function arrMaxNum(arr){
var maxNum = null;
for (var i = 0; i < arr.length; i++) {
var item =parseInt(arr[i]);
if(item){
if(!maxNum){
maxNum = item;
}
item>maxNum ? maxNum =item : null;
}
};
return maxNum;
};
//獲取數組最小值(排除0)
function arrMinNum(arr){
var minNum = null;
for (var i = 0; i < arr.length; i++) {
var item =parseInt(arr[i]);
if(item){
if(!minNum){
minNum = item;
}
item<minNum ? minNum =item : null;
}
};
return minNum;
};
//獲取數組平均值(排除0)
function arrAverageNum(arr){
var sum = 0;
var count = 0
for (var i = 0; i < arr.length; i++) {
var item =parseInt(arr[i]);
if(item){
sum += item;
count++;
}
};
return ~~(sum/count*100)/100;
};