Skip to content

Commit 703e094

Browse files
committed
Refactor: Make the default unit price a constant
Instead of returning directly 299 in case of the tier being undefined, the default unit price is stored in a constant with that name
1 parent db44072 commit 703e094

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

exercises/tiered_pricing/solutions/xetxeberria-ts/src/tieredPricing.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ export function tieredPricing(licenseAmount: number): number {
1313
}
1414

1515
function calculateLicensePrice(licenseAmount: number): number {
16+
const defaultUnitPrice = 299;
1617
const applicableTier = priceTiers
1718
.filter((tier) => licenseAmount >= tier.minAmount)
1819
.pop();
19-
return applicableTier?.unitPrice || 299;
20+
return applicableTier?.unitPrice || defaultUnitPrice;
2021
}

0 commit comments

Comments
 (0)