Skip to content

Instantly share code, notes, and snippets.

@tripdog
Created June 17, 2021 04:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tripdog/5df90df483d5564220efec3f3e0b378c to your computer and use it in GitHub Desktop.
Save tripdog/5df90df483d5564220efec3f3e0b378c to your computer and use it in GitHub Desktop.
Write a function that returns the biggest number from an array

Write a function that returns the biggest number from an array.

function maxNum(arr) {
    let max = 0
    for (let i = 0; i < arr.length; i++){
        if (arr[i] > max ) {
            max = arr[i]
        }
    }
    return max
}
console.log(maxNum([2, 4, 8, 0, 5, 10]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment