filmov
tv
Javascript Function - Find max number in an array
Показать описание
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.
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
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.
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