Advertisement
Guest User

Untitled

a guest
Jun 10th, 2020
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function energyBooster(input){
  2.     let fruit = input.shift();
  3.     let size = input.shift();
  4.     let numberSets = Number(input.shift())
  5.  
  6.     let sum = 0;
  7.     let price = 0;
  8.     let discount = 0;
  9.  
  10.     if(fruit === 'Watermelon'){
  11.         if(size === 'small'){
  12.             sum = 2 * 56;
  13.         } else {
  14.             sum = 5 * 28.70;
  15.         }
  16.  
  17.     } else if(fruit === 'Mango'){
  18.         if(size === 'small'){
  19.             sum = 2 * 36.66;
  20.         } else {
  21.             sum = 5 * 19.60;
  22.         }
  23.  
  24.     } else if(fruit === 'Pineapple'){
  25.         if(size === 'small'){
  26.             sum = 2 * 42.10;
  27.         } else {
  28.             sum  = 5 * 24.80;
  29.         }
  30.     } else if(fruit === 'Raspberry'){
  31.         if(size === 'small'){
  32.             sum = 2 * 20;
  33.         } else {
  34.             sum = 5 * 15.20;
  35.         }
  36.     }
  37.     price = numberSets * sum;
  38.  
  39.     if(price >= 400 && price <= 1000){
  40.         discount = price * 0.85;
  41.         console.log(`${discount.toFixed(2)} lv.`);
  42.     } else if (price > 1000){
  43.         discount = price * 0.50;
  44.         console.log(`${discount.toFixed(2)} lv.`);
  45.     } else {
  46.         console.log(`${price.toFixed(2)} lv.`);
  47.     }
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement