javascript max of two values code example

Example 1: javascript max number

MAX_SAFE_INTEGER = 9007199254740991

Example 2: max method in js

// Math.max
finding maximum number

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

Example 3: how to find max number in array javascript

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

Example 4: find max and min value in array javascript

var numbers = [1, 2, 3, 4];
Math.max(...numbers) // 4
Math.min(...numbers) // 1

Example 5: js return the highest and lowest number

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