Announcement

Collapse
No announcement yet.

max value in a list

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • max value in a list

    Hello,

    How do you find the max value in a list of numbers?



  • #2
    Is this related to eSignal?

    Code:
    function largest(arr) {
        if(arr.length == 0){
            return 0;
        }
        let max = arr[0];
     
        for (let i = 1; i < arr.length; i++) {
            if (arr[i] > max){
                max = arr[i];
            }  
        }
           
        return max;
    }

    Comment

    Working...
    X