Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get largest number in array javascript

const array1 = [1, 3, 2];

Math.max(...array1);
// expected output: 3
Comment

find the largest number in array javascript

const result = (data) => {
  let max = 0;
  for (let i = 0; i < data.length; i++) {
    if (data[i] > max) {
      max = data[i];
    }
  }
  console.log("===> :: max", max);
}

const inputData = [2, 3, 5, 4, 54, 69, 4, 44, 3, 6, 45, 6, 4, 6]
result(inputData);
Comment

find largest number from an array in JavaScript

const array = [3 , 6, 2, 56, 32, 5, 89, 32];
let largestNum= array[0];

for (let i=1; i<array.length; i++){
    if (array[i]>largestNum) {
        largestNum = array[i];
    }
};
console.log(largestNum);
Comment

js largest number in array

array.reduce((max,x) => max < x ? x : max);
Comment

javascript largest number in array

const max = arr => Math.max(...arr);
Comment

find highest value in array javascript

const array = [10, 2, 33, 4, 5];

console.log(Math.max(...array)
)
Comment

Get the Largest Element of an Array, array js

const getLargest = (arr) =>
  arr.reduce((largest, num) => Math.max(largest, num));
const arr = [13, 7, 11, 3, 9, 15, 17];
console.log(getLargest(arr)); // 17
Comment

find highest number in array javascript

function findHighestNumber(nums) {
	
	let inputs = nums.filter((val, i) => nums.indexOf(val) === i)
	let max = Math.max(...nums);
	let min = Math.min(...nums);
  
   return max + (-min);
}

console.log(difference([1, 7, 18, -1, -2, 9]));
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

js highest number in array

var arr = [1, 2, 3];
var max = arr.reduce(function(a, b) {
  return Math.max(a, b);
}, -Infinity);
Comment

how to find max number in array javascript

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

Return the highest number in Arrays in JavaScript

function largestOfFour(arr) {
  return arr.map(Function.apply.bind(Math.max, null));
}
Comment

get largest no in the array javascript

//For Values
var arr =[1,10,3]
var min = Math.min.apply(null, arr),
    max = Math.max.apply(null, arr);

//For Objects
var arr = [{a: 1},{a: 10},{a: 3}]
var values = arr.map(val => val.a);
var max = Math.max.apply(null, values);
console.log(max)
Comment

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
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

javascript set value to the largest value in an array

//get min/max value of arrays
function getArrayMax(array){
   return Math.max.apply(null, array);
Comment

js highest number in array

function maxFromArray(array) {
  return array.reduce(function(a, b) {
    return Math.max(a, b);
  }, -Infinity);
}
Comment

find the largest array from an array in javascript

const numbers = [
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9, 10, 11],
];

let largestArray = numbers[0].length;
for (let i = 1; i < numbers.length; i++) {
  if (numbers[i].length > largestArray) {
    largestArray = numbers[i];
    for (let j = 0; j < largestArray.length; j++) {
       console.log(numbers[i][j]);
    }
  }
}

//it will print 7, 8, 9, 10, 11 as these numbers are in largest array;
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

PREVIOUS NEXT
Code Example
Javascript :: execcommand js 
Javascript :: callback function js 
Javascript :: vue localstore 
Javascript :: react native create text file 
Javascript :: JavaScript Finding HTML Element by Id 
Javascript :: use js to get select value 
Javascript :: string splice javascript 
Javascript :: sequelize max 
Javascript :: remove all sign that is not a-b in string js 
Javascript :: react native flexbox 2 columns 1 fixed width 
Javascript :: javscript match word in string 
Javascript :: how to get table last row id in jquery 
Javascript :: async function syntax 
Javascript :: axios post nuxt 
Javascript :: sort array by date in javascript 
Javascript :: javascript sleep 1 second" 
Javascript :: TypeError: Object of type ndarray is not JSON serializable 
Javascript :: chrome storage local example 
Javascript :: app bar in react native 
Javascript :: server side rendering in agular 
Javascript :: add google analytics to react 
Javascript :: is undefined false in javascript 
Javascript :: revert order elements inside array 
Javascript :: submit form without redirection 
Javascript :: remove spaces from string javascript 
Javascript :: react pass props to children 
Javascript :: background image not loading from a link react 
Javascript :: removes null and false values from an array 
Javascript :: js maths 
Javascript :: javascript string proper case 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =