Javascript Function - Find max number in an array

Publié le: 09 novembre 2020
sur la chaîne: Kathryn Sherazi
282
5

This function passes in an array and returns the max or highest number of that array. I have provided two different examples of how this can be accomplished.

For the first example, we are returning the largest number. This is done by comparing the first number of the array to every other number in the array by using a for loop and if statement. As the for loop "loops" through the array, if the current number is greater than the largest number (first number of the array), then the current number equals the largest number, and the max is returned.

The second option uses the Math.max method, which accomplishes the same task.

Read more about Math.max:
https://developer.mozilla.org/en-US/d...

For the production of this video, I used Visual Code with the Quokka extension, Screencastify, and music from Adobe Stock (Song: Toss the Salt)

For more coding news, job search recommendations, and everyday chatter, follow me on Twitter @KSherazi2


Sur cette page du site, vous pouvez voir la vidéo en ligne Javascript Function - Find max number in an array durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Kathryn Sherazi 09 novembre 2020, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 282 fois et il a aimé 5 téléspectateurs. Bon visionnage!