Try to avoid stack overflow in js

This commit is contained in:
Björn Fromme
2018-10-09 12:16:21 +02:00
parent db71b70863
commit 65e27730df
@@ -209,10 +209,11 @@
}, 'json');
},
calculatePrice (roomCode, nights) {
for (const room of this.availableRooms) {
if (room.code === roomCode) {
return room.price + (nights - room.minNights) * room.additionalNightPrice;
}
const room = this.availableRooms.find(obj => {
return obj.code === roomCode;
});
if (room) {
return room.price + (nights - room.minNights) * room.additionalNightPrice;
}
return null;
}
@@ -234,7 +235,8 @@
}
},
onDayCreate: (dObj, dStr, fp, dayElem) => {
const day = dayjs(dayElem.dateObj).format('YYYY-MM-DD');
const day = dayElem.dateObj.getFullYear() + "-" + ("0" + dayElem.dateObj.getMonth()).slice(-2)
+ "-" + ("0"+(dayElem.dateObj.getDate()+1)).slice(-2);
if (day in this.availableDates) {
dayElem.classList.add('available');
}