Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js get max value in an array

const myArray = [1, 14, 32, 7];

const maxValue = Math.max(...myArray);

console.log(maxValue); // 32
Comment

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);
});
Comment

find maximum number in array

#include <stdio.h>
int main() {
    int i, n;
    float arr[100];
    printf("Enter the number of elements (1 to 100): ");
    scanf("%d", &n);

    for (i = 0; i < n; ++i) {
        printf("Enter number%d: ", i + 1);
        scanf("%f", &arr[i]);
    }

    // storing the largest number to arr[0]
    for (i = 1; i < n; ++i) {
        if (arr[0] < arr[i])
            arr[0] = arr[i];
    }

    printf("Largest element = %.2f", arr[0]);

    return 0;
}
Comment

Find the maximum number of an array js

function getMaxOfArray(numArray) {
    return Math.max.apply(null, numArray);
}
Comment

Max Number from Array in JS

function arrayMax(array) {
  return array.reduce(function(a, b) {
    return Math.max(a, b);
  });
}

function arrayMin(array) {
  return array.reduce(function(a, b) {
    return Math.min(a, b);
  });
}
Comment

find max value in array javascript

// find maximum value of array in javascript
// array reduce method
const arr = [49,2,71,5,38,96];
const max = arr.reduce((a, b) => Math.max(a, b));
console.log(max); // 96

// math.max apply method
const max_ = Math.max.apply(null, arr);
console.log(max_); // 96

// or math.max spread operator method
const max__ = Math.max(...arr);
console.log(max__); // 96
Comment

how to find max number in array javascript

const array1 = [1, 3, 2];
console.log(Math.max(...array1));
Comment

js how to find max value in an array

(function () {
  const arr = [23, 65, 3, 19, 42, 74, 56, 8, 88];

  function findMaxArrValue(arr) {
    if (arr.length) {
      let max = -Infinity;

      for (let num of arr) {
        max = num > max ? num : max;
      }
      return max;
    }
    return 0; // or any value what you need
  }

  console.log(findMaxArrValue(arr)); // => 88
})();
Comment

find the maximum no. in array js

function findMaxArrValue(numbers) {
  let max = 0;
  numbers.forEach((number) => {if (number > max) {max = number}});
  return max;
}

console.log(findMaxArrValue([23, 69, 55, 31, 75, 100, 82]));
//Output 100
Comment

find the max number in an array js

var myPersons__ = document.querySelectorAll('.avtrlnk');
var maxId__ = [];
    
	for(var x = 0; x < myPersons__.length; ++x) {
		maxId__[x] = myPersons__[x].value;
	}
	myPersons__ = parseInt(maxId__.sort()[x-1]) + 1;
Comment

find maximum value in the array javascript

const findMax = (arr)=>{
    let max = 0 ;
   for (let index = 0; index < arr.length; index++) {
        if (max < arr[index] && max != arr[index]) {
          max = arr[index];     
        }  
   }
        return max;
    
}

//if you find this answer is useful ,
//upvote ⇑⇑ , so can the others benefit also . @mohammad alshraideh ( ͡~ ͜ʖ ͡°)
Comment

maximum number from Array

---without sort method---
public static int maxValue( int[]  n ) {

int max = Integer.MIN_VALUE;

for(int each: n)

if(each > max)

max = each;

 
return max;
  
---with sort method---
public static int maxValue( int[]  n ) {

Arrays.sort( n );

return  n [ n.lenth-1 ];

}
Comment

Find the maximum number of an array js

Math.max(10, 20);   //  20
Math.max(-10, -20); // -10
Math.max(-10, 20);  //  20
Comment

maximum number of an array

var arr = [1, 2, 3];
var max = Math.max(...arr);
Comment

PREVIOUS NEXT
Code Example
Javascript :: passing data in route react 
Javascript :: nodejs read file to array 
Javascript :: hide checkbox jquery 
Javascript :: destructuring assignment in javascript 
Javascript :: object properties 
Javascript :: reference data types in javascript 
Javascript :: know when recyclerview is on the last item 
Javascript :: how to add animation over image in Javascript 
Javascript :: es6 hashset 
Javascript :: graphql json schema 
Javascript :: discord.js add role command 
Javascript :: how to disable previous date in datepicker using angular 6 
Javascript :: vuejs how use this.$slots.default 
Javascript :: id in class selector jquery 
Javascript :: chart js clear out chart 
Javascript :: mongodb aggregate $filter check if exists 
Javascript :: create immutable object in javascript 
Javascript :: add a string to list jquery 
Javascript :: convert javascript date into excel date 
Javascript :: fetch log api response time 
Javascript :: ex: javascript loop array 
Javascript :: circle collision javascript 
Javascript :: react-metismenu-router-link 
Python :: epa meaning 
Python :: sqlalchemy python install 
Python :: python count files directory 
Python :: python change recursion depth 
Python :: dotenv python 
Python :: items of a list not in another list python 
Python :: combine path python 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =