Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function addBags(input) {
- let over20Price = Number(input[0]);
- let suitcaseWeight = Number(input[1]);
- let daysToTrip = Number(input[2]);
- let suitcasesNumber = Number(input[3]);
- price = 0;
- if (suitcaseWeight < 10) {
- price = over20Price * 0.20;
- } else if (suitcaseWeight >= 10 && suitcaseWeight <= 20) {
- price = over20Price * 0.50;
- } else {
- price = over20Price;
- }
- if (daysToTrip < 7) {
- price += price * 0.40;
- } else if (daysToTrip >= 7 && daysToTrip <= 30) {
- price += price * 0.15;
- } else {
- price += price * 0.10;
- }
- let totalPrice = price * suitcasesNumber;
- console.log(`The total price of bags is: ${totalPrice.toFixed(2)} lv.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment