reworked sumseatprices with reduce
This commit is contained in:
@@ -103,9 +103,12 @@ function appendOption(inSelector: string, inArr: I.TypeBuyerTypeArr): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sumSeatPrices(): string {
|
function sumSeatPrices(): string {
|
||||||
let overallPrice: number = 0;
|
return config.state.selectedSeatsArr.map(getSeatPrice)
|
||||||
|
.reduce((prev, curr) => prev + curr)
|
||||||
|
.toFixed(2);
|
||||||
|
}
|
||||||
|
|
||||||
config.state.selectedSeatsArr.forEach(arr => {
|
function getSeatPrice(arr: string[]) {
|
||||||
const seatID: string = arr[0];
|
const seatID: string = arr[0];
|
||||||
const buyertypeID: string = arr[1];
|
const buyertypeID: string = arr[1];
|
||||||
const selectedSeat: I.JSCSelectedSeat = config.state.selectedSeatsObj[seatID];
|
const selectedSeat: I.JSCSelectedSeat = config.state.selectedSeatsObj[seatID];
|
||||||
@@ -116,9 +119,8 @@ function sumSeatPrices(): string {
|
|||||||
const seatPrice: number | undefined = XMLHelper.getPriceByBuyerTypeID(buyertypeID, pricescaleObj);
|
const seatPrice: number | undefined = XMLHelper.getPriceByBuyerTypeID(buyertypeID, pricescaleObj);
|
||||||
|
|
||||||
if (seatPrice)
|
if (seatPrice)
|
||||||
overallPrice += seatPrice;
|
return seatPrice;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
return overallPrice.toFixed(2);
|
return 0;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user