```js
const minMax = (arr=[]) => { if( arr.length==1 ) return [arr[0],arr[0]];
const result=[Infinity, -Infinity];
for( let i=0;i < arr.length;i++ ) {
result[0] = arr[i] < result[0] ? arr[i]: ((result[1] = arr[i] >
result[1]? arr[i]: result[1]), result[0]) ;
}
return result;
}
Would be slightly faster to only do the max if it's not a min. Which fails
if there's only 1 number to compare.
On Mon, Oct 2, 2017 at 9:12 AM, Xavier Stouder <[email protected]> wrote:
> JDecker: Just added your solution on the benchmark, it beats every
> others solution and it's a elegant solution.
>
> Kai Zhu: We can't see the screenshot. But please take in consideration
> that it's been a long time that ECMAScript isn't only used in webapp,
> and that some of applications using it can eat more than a million
> numbers.
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss