Skip to content

Instantly share code, notes, and snippets.

@paulohfev
Created April 4, 2023 00:28
Show Gist options
  • Save paulohfev/e38ba8179119c7091ac0f33d65c11551 to your computer and use it in GitHub Desktop.
Save paulohfev/e38ba8179119c7091ac0f33d65c11551 to your computer and use it in GitHub Desktop.
Function for finding the highest number in a list of numbers
function find_max(nums) {
let max_num = Number.NEGATIVE_INFINITY; // smaller than all other numbers
for (let num of nums) {
if (num > max_num) {
max_num = num
}
}
return max_num;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment