<div>
More info on:
<br /><br />
<a href="https://daily-dev-tips.com/posts/javascript-find-min-max-from-array-of-objects/" target="_blank">Daily Dev Tips</a>
<br /><br />
See console for output 🙋
</div>
body {
font-family: Roboto,"Helvetica Neue",Arial,sans-serif;
display: grid;
place-items: center;
min-height: 100vh;
text-align: center;
font-size: 2rem;
}
const users = [
{ name: 'Nicole', age: 31 },
{ name: 'Chris', age: 33 },
{ name: 'Yaatree', age: 2 },
{ name: 'Sanne', age: 29 }
]
const highest = users.reduce((previous, current) => {
return current.age > previous.age ? current : previous;
})
console.log('highest', highest);
const lowest = users.reduce((previous, current) => {
return current.age < previous.age ? current : previous;
})
console.log('lowest', lowest);
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.