Answer to Question #278568 in HTML/JavaScript Web Application for Lovely

Question #278568

Hotel bill

Given a charge per day dayCharge based on category and number of days customer stayed days as inputs,write js arrow function to return the total bill with discount



1
Expert's answer
2021-12-11T18:45:00-0500
const hotelBill = (dayCharge, days) => {

    let discount = 0;




    if (days > 2 && days <= 15) {

        discount = 5;

    } else if (days > 15) {

        discount = 15;

    }




    return dayCharge * days - (dayCharge * days * discount) / 100

}




console.log(hotelBill(200, 3));

console.log(hotelBill(180, 1));

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS