js 创建函数getMax,传递3个参数,返回三个数字中的最大值。

创建函数getMax,传递3个参数,返回三个数字中的最大值。
function getMax3(a,b,c){
if(a>b && a>c){
return a;
}else if(b>a && b>c){
return b;
}else{
return c;
}
}
console.log('最大值为: '+getMax3(15,2,36));
/
//方法二
/

function getMax3(a,b,c){
var max=a>b ? a : b;
return max>c ? max : c;
}
var max=getMax3(3,2,7);
console.log(max);

猜你喜欢

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