Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

find largest number from an array in JavaScript

const array = [3 , 6, 2, 56, 32, 5, 89, 32];
let largestNum= array[0];

for (let i=1; i<array.length; i++){
    if (array[i]>largestNum) {
        largestNum = array[i];
    }
};
console.log(largestNum);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #find #largest #number #array #JavaScript
ADD COMMENT
Topic
Name
2+3 =