max value in array javascript
// For large data, it's better to use reduce. Supose arr has a large data in this case: const arr = [1, 5, 3, 5, 2]; const max = arr.reduce((a, b) => { return Math.max(a, b) }); // For arrays with relatively few elements you can use apply: const max = Math.max.apply(null, arr); // or spread operator: const max = Math.max(...arr);
get largest number in array javascript
const array1 = [1, 3, 2]; Math.max(...array1); // expected output: 3
Source: developer.mozilla.org
javascript max array
var values = [3, 5, 6, 1, 4]; var max_value = Math.max(...values); //6 var min_value = Math.min(...values); //1
find max and min value in array javascript
var numbers = [1, 2, 3, 4]; Math.max(...numbers) // 4 Math.min(...numbers) // 1
Source: www.jstips.co
jsx return greatest number between two numbers
Math.max(5, 10);
max value in an array
console.log(Math.max(1, 3, 2)); // expected output: 3 console.log(Math.max(-1, -3, -2)); // expected output: -1 const array1 = [1, 3, 2]; console.log(Math.max(...array1)); // expected output: 3