JS: Get Max/Min Value of Array

By Xah Lee. Date: . Last updated: .

Get Maximum Element of Array

Math.max(...xArray)

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

Get Minimum Element of Array

Math.min(...xArray)

const x = [1,2,3];
console.log( Math.min(...x) )
// 1