Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function bike(countYoung, countOld, type) {
- countYoung = +countYoung;
- countOld = +countOld;
- let price = 0;
- let discount = 0;
- let allPrat = countOld + countYoung;
- if (type == "trail") {
- price = (5.50 * countYoung) + (7 * countOld);
- } else if (type == "cross-country") {
- price = (8 * countYoung) + (9.50 * countOld);
- } else if (type == "downhill") {
- price = (12.25 * countYoung) + (13.75 * countOld);
- } else if (type == "road") {
- price = (20 * countYoung) + (21.50 * countOld);
- }
- if (allPrat >= 50) {
- discount = price - (price * 0.75);
- }
- let giveSum = (price - discount) * 0.95;
- console.log(`${giveSum.toFixed(2)}`);
- }
- bike(30, 25, "cross-country");
- //bike(3, 40, "road");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement