[javascript] Find the min/max element of an array in JavaScript