Files
web/utils/loyaltyTable.ts
2024-06-28 10:13:32 +02:00

14 lines
337 B
TypeScript

import { ComparisonLevel } from "@/types/components/loyalty/blocks"
export function getHighestLevel(levels: ComparisonLevel[]) {
return levels.reduce(
(acc: ComparisonLevel | null, level: ComparisonLevel) => {
if (!acc) {
return level
}
return level.level > acc.level ? level : acc
},
null
)
}