Skip to content

Commit

Permalink
fix: make sure startDate is actually the first date
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusk committed Jan 24, 2022
1 parent c035213 commit b712c25
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions TypeScript/TollCalculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ class TollCalculator {
}

getTotalTollFee(vehicle: Vehicle, dates: Date[]) {
const startDate = dates[0];
const sortedDates = [...dates].sort();
const startDate = sortedDates[0];
let lastBillingDate = null;
let tempFee = null;
let totalFee = 0;

dates.sort().forEach((date: Date) => {
sortedDates.sort().forEach((date: Date) => {
if (!this.isSameDay(date, startDate)) {
throw "Billings must be in the same day.";
}
Expand Down

0 comments on commit b712c25

Please sign in to comment.