Created
April 4, 2023 00:28
-
-
Save paulohfev/e38ba8179119c7091ac0f33d65c11551 to your computer and use it in GitHub Desktop.
Function for finding the highest number in a list of numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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