63   JS

在不使用循环的情况下,查找数组最大值,可通过递归调用函数来实现


function findMax(arr,i,max){
	if(arr[i]>=max){
		max=arr[i];
	}
	if(i

其实更简洁的方式是通过Math

var arr = [2,4,1,6,7];
var max = Math.max.apply(Math,arr);



Leave a Reply

Your email address will not be published. Required fields are marked *