Skip to content

Commit

Permalink
Fix no initial value in .reduce()
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchernchong committed Jul 20, 2024
1 parent 9fdc906 commit 8d1a70c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/components/KeyStatistics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,19 @@ export const KeyStatistics = ({ data }: KeyStatisticsProps) => {
<p>
Highest Year:{" "}
{
data.reduce((max, item) => (item.total > max.total ? item : max))
.year
data.reduce(
(max, item) => (item.total > max.total ? item : max),
{ total: -Infinity, year: 0 },
).year
}
</p>
<p>
Lowest Year:{" "}
{
data.reduce((min, item) => (item.total < min.total ? item : min))
.year
data.reduce(
(min, item) => (item.total < min.total ? item : min),
{ total: Infinity, year: 0 },
).year
}
</p>
</div>
Expand Down

0 comments on commit 8d1a70c

Please sign in to comment.