Answers for "how to find largest value in an array"

0

Find largest number from array by function in javascript

function largestElements(numbers) {
    var largest = 0;
    for (let i = 0; i < numbers.length; i++) {
        var elements = numbers[i];
        if (elements > largest) {
            largest = elements;
        }
    }
    return largest;
}
const numbers = [2, 3, 4, 8, 5, 2, 4];
console.log(largestElements(numbers));
//Output: 8
Posted by: Guest on December-16-2021

Code answers related to "how to find largest value in an array"

Code answers related to "BASIC"

Browse Popular Code Answers by Language