Some ES6 magic for you, using the spread syntax:

function biggestNumberInArray(arr) {
  const max = Math.max(...arr);
  return max;
}

Actually, a few people have answered this question in a more detailed fashion than I do, but I would like you to read this if you are curious about the performance between the various ways of getting the largest number in an array.

Answer from wentjun on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-program-to-find-largest-element-in-an-array
JavaScript Program to Find Largest Element in an Array - GeeksforGeeks
July 23, 2025 - ... function largestElement(arr) ... a for loop, iterate through the array, comparing each element to a running largest value, updating it if a larger element is encountered, and returning the final largest value....
🌐
Built In
builtin.com › articles › javascript-array-max
3 Methods to Find the JavaScript Array Max | Built In
More on JavaScriptHow to Pass an Array From Java to JavaScript · In this traditional approach, we loop through each element in the array and compare it with a previously stored maximum value.
🌐
OneCompiler
onecompiler.com › javascript › 3xdvdamus
find largest number in array javascript using for loop - JavaScript - OneCompiler
let mobiles = ["iPhone", "Samsung", "Pixel"]; // accessing an array console.log(mobiles[0]); // changing an array element mobiles[3] = "Nokia"; Arrow Functions helps developers to write code in concise way, it’s introduced in ES6. Arrow functions can be written in multiple ways. Below are couple of ways to use arrow function but it can be written in many other ways as well. ... const numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] const squaresOfEvenNumbers = numbers.filter(ele => ele % 2 == 0) .map(ele => ele ** 2); console.log(squaresOfEvenNumbers);
🌐
TutorialsPoint
tutorialspoint.com › How-to-find-the-largest-number-contained-in-a-JavaScript-array
How to find the largest number contained in a JavaScript array?
In this example, we have declared a number array as arr, then traverse it using for loop to update the value of largest to the largest number in the array. The reduce() method in JavaScript accepts a function that acts as a reducer function for the array and returns a single value that will be the result of the function's calculations.
🌐
Quora
quora.com › How-do-you-write-a-program-in-JavaScript-to-find-the-largest-number-in-an-array-using-a-loop
How to write a program in JavaScript to find the largest number in an array using a loop - Quora
Answer (1 of 3): I don't really program in JS, but this is the general recipe, so you will still have some fun implenting it, 1. Easiest way, if you have a sort function available, is to sort the array first.
🌐
freeCodeCamp
freecodecamp.org › news › three-ways-to-return-largest-numbers-in-arrays-in-javascript-5d977baa80a1
Three ways you can find the largest number in an array using JavaScript
October 17, 2016 - Now that you have a method to return the largest number in a array, you can loop through each sub-arrays with the map() method and return all largest numbers.
🌐
Medium
medium.com › @amitsharma_24072 › 3-efficient-ways-to-find-maximum-value-in-javascript-arrays-515463ebd17
3 Efficient Ways to Find Maximum Value in JavaScript Arrays | by Amit Sharma | Medium
July 11, 2024 - We can use this method to sort the array in descending order and then take the first element as the maximum value: const arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3]; arr.sort((a, b) => { return b - a; }); const max = arr[0]; console.log(max); // Output: ...
Find elsewhere
🌐
YouTube
youtube.com › watch
Find Largest Number in an Array - YouTube
Want to start building things with your new JS skills but don't know where to start? I've created a free resource where a community builds together and learn...
Published   November 9, 2017
🌐
YouTube
youtube.com › watch
Find the largest number in an array JavaScript Tutorial - YouTube
In this tutorial, you’ll learn how to find the largest number in an array with JavaScript which is a common coding exercise asked at Junior Developer intervi...
Published   February 6, 2019
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Return Largest Numbers in Arrays-applying for loop - JavaScript - The freeCodeCamp Forum
September 9, 2022 - Hello all, i tried this challenge by sort() method and its working. But the code is getting lengthy. Can someone help me applying a for loop in my code? function largestOfFour(arr) { let ans =[] let elem1 = arr[0].sort(function(a,b){ return b-a}) ans.push(elem1[0]); let elem2 = arr[1].sort(function(a,b){ return b-a}) ans.push(elem2[0]); let elem3 = arr[2].sort(function(a,b){ return b-a}) ans.push(elem3[0]); let elem4 = arr[3].sort(function(a,b){ return b-a}) ans.push(elem4...
🌐
CoreUI
coreui.io › answers › how-to-find-the-maximum-value-in-an-array-in-javascript
How to find the maximum value in an array in JavaScript · CoreUI
September 21, 2025 - This is the same approach we use in CoreUI components for calculating chart scales and determining data ranges in our analytics components. For arrays with non-numeric values, filter first: Math.max(...array.filter(Number)). For very large arrays (>100k elements), consider using a traditional loop to avoid stack overflow issues.
🌐
sebhastian
sebhastian.com › find-largest-number-array-javascript
How To Find the Largest Number in a JavaScript Array | sebhastian
July 9, 2021 - And that’s how you use the forEach() method to find the largest number in an array.
🌐
Bomberbot
bomberbot.com › javascript › three-ways-you-can-find-the-largest-number-in-an-array-using-javascript
Three ways you can find the largest number in an array using JavaScript - Bomberbot
The loop ends, and we return 54 as the maximum value. The time complexity of this approach is O(n) since we have to iterate through all n elements of the array. The space complexity is O(1) though, as we only use a single max variable besides the input array. While this method is simple to understand and implement, there are more concise ways we can find the max value by leveraging JavaScript‘s built-in methods.
🌐
YouTube
youtube.com › watch
How to Get the Largest Number in an Array | Find the Largest Number from Array - YouTube
How to get the largest number in an array or how to find the largest number from array. How to find largest number in array in JavaScript? It is a common jav...
Published   January 26, 2023