Given an array as input,find the largest number in the array.Using Javascript

let arr=[5,18,26,30,40,6];
    function largest(arr)
     {
        let i;
        let max = arr[0];
        for (i = 1; i < arr.length; i++)
         {
            if (arr[i] > max)
                max = arr[i];
        }
        
    return max;
}
    
    
    console.log('Max='+largest(arr));
    

Check Also

How to debugg our flutter application

Debugging a Flutter application involves a variety of techniques and tools to identify and fix …

Leave a Reply

Your email address will not be published. Required fields are marked *