求任意个数数字最大值

最大值

    <script>
        function getMax(){
    
    
            var max = arguments[0];
            for(var i = 0; i < arguments.length - 1; i++){
    
    
                if(arguments[i] > max){
    
    
                    max = arguments[i];
                }
            }
            return max;
        }
        console.log(getMax(1,2,3,4,5,6,7,8));
        console.log(getMax(1,5,3));
    </script>

猜你喜欢

转载自blog.csdn.net/qq_41127869/article/details/115256092
今日推荐