Can you solve this?
Select an answer Select an answer Select an answer
function find_max(nums) {
let max_num = Number.NEGATIVE_INFINITY; // smaller than all other numbers
for (let num of nums) {
if (num > max_num) {
// (Fill in the missing line here)
}
}
return max_num;
}
def find_max(nums):
max_num = float("-inf") # smaller than all other numbers
for num in nums:
if num > max_num:
# (Fill in the missing line here)
return max_num
int find_max(int nums[], int len)
{
int i, max_num = nums[0];
for (i = 1; i < len; i ++)
if (nums[i] > max_num)
// (Fill in the missing line here)
return max_num;
}