how to find maximum value in array code example
Example 1: Find the maximum number of an array js
var arr = [1, 2, 3];
var max = arr.reduce(function(a, b) {
return Math.max(a, b);
});
Example 2: java find biggest number in array
for (int counter = 1; counter < decMax.length; counter++)
{
if (decMax[counter] > max)
{
max = decMax[counter];
}
}
System.out.println("The highest maximum for the December is: " + max);
Example 3: max element in array
int max;
max=INT_MIN;
for(int i=0;i<ar.length();i++){
if(ar[i]>max){
max=ar[i];
}
Example 4: how to find max number in array javascript
const array1 = [1, 3, 2];
console.log(Math.max(...array1));
Example 5: Find the maximum number of an array js
Math.max(10, 20);
Math.max(-10, -20);
Math.max(-10, 20);