Javascript Function - Find max number in an array

Pubblicato il: 09 novembre 2020
sul canale di: 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


In questa pagina del sito puoi guardare il video online Javascript Function - Find max number in an array della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Kathryn Sherazi 09 novembre 2020, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 282 volte e gli è piaciuto 5 spettatori. Buona visione!