JSFiddle - React, Tailwind, and code Playground
by Lamik
HTML
<button onclick="findReduce()">find by reduce</button>
<div id="resultReduce"></div>
<button onclick="findSort()">find by sort</button>
<div id="resultSort"></div>
<button onclick="clenResults()">clean</button>
JavaScript
let a = Array(10000).fill(0).map( (el,i)=> ({"x": "8/11/2009", "y": Math.random() }));
function findReduce() {
let max = a.reduce((a,b)=>a.y>b.y?a:b).y;
resultReduce.innerHTML=max;
}
function findSort() {
let max = a.sort((a,b)=>b.y-a.y)[0].y;
resultSort.innerHTML=max;
}
function clenResults() {
resultReduce.innerHTML = '';
resultSort.innerHTML = '';
}