Skip to content

Commit

Permalink
fix: switch map to reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
ludtkemorgan committed Nov 9, 2023
1 parent 5bf8306 commit 3e9a8da
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions backend/core/src/email/email.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ const formatUnitDetails = (
label: string,
pluralLabel?: string
): string => {
const mappedField = units
.map((unit) => (unit[field] ? Number.parseFloat(unit[field]) : null))
.filter((value) => value)
const mappedField = units.reduce((values, unit) => {
if (unit[field]) {
values.push(Number.parseFloat(unit[field]))
}
return values
}, [])
if (mappedField?.length) {
const minValue = Math.min(...mappedField)
const maxValue = Math.max(...mappedField)
Expand Down

0 comments on commit 3e9a8da

Please sign in to comment.