Advertisement
dimoBs

Untitled

Sep 16th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function bike(countYoung, countOld, type) {
  2.     countYoung = +countYoung;
  3.     countOld = +countOld;
  4.     let price = 0;
  5.     let discount = 0;
  6.     let allPrat = countOld + countYoung;
  7.  
  8.  
  9.  
  10.     if (type == "trail") {
  11.         price = (5.50 * countYoung) + (7 * countOld);
  12.     } else if (type == "cross-country") {
  13.         price = (8 * countYoung) + (9.50 * countOld);
  14.     } else if (type == "downhill") {
  15.         price = (12.25 * countYoung) + (13.75 * countOld);
  16.     } else if (type == "road") {
  17.         price = (20 * countYoung) + (21.50 * countOld);
  18.     }
  19.     if (allPrat >= 50) {
  20.         discount = price - (price * 0.75);
  21.     }
  22.  
  23.     let giveSum = (price - discount) * 0.95;
  24.  
  25.     console.log(`${giveSum.toFixed(2)}`);
  26.  
  27.  
  28. }
  29.  
  30.  
  31.  bike(30, 25, "cross-country");
  32. //bike(3, 40, "road");
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement