```javascript
function getMax(arr) {
let max = arr[0];
for (let i = 1; i < arr.length; i++) {
if (arr[i] > max) {
max = arr[i];
}
}
return max;
}
//优化后的代码:
function getMax(arr) {
let max = -Infinity;
for (let num of arr) {
if (num > max) {
max = num;...