利用函数求任意个数的最大值
<script> function getMax() { let max = arguments[0]; for (let i = 0; i < arguments.length; i++) { if (arguments[i] > max) { max = arguments[i]; } } return max; } console.log(getMax(5, 3, 4, 9)); console.log(getMax(10, 15, 32, 15, 40)); console.log(getMax(20, 45, 31, 60, 54)); </script>