JS_数组:创建函数getMax,传递一个参数(数组),返回最大值

function getMax(a){
    var max=a[0];
    for(var i=1;i<a.length;i++){
        if(a[i]>max){
            max=a[i];
        }
    }
    console.log(max);
}
getMax([23,85,74,46,95,10,211,985,1111]);

猜你喜欢

转载自blog.csdn.net/Andrexc/article/details/89348809