Advertisement
Liliana797979

club

Dec 31st, 2020
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function club(input) {
  2.     let target = Number(input[0]);
  3.     let nameCocktail = input[1];
  4.     let cocktailNum = parseInt(input[2]);
  5.     let index = 1;
  6.  
  7.     let totalPrice = 0;
  8.     let lengthCoctail = input[index];
  9.  
  10. while(index < input.length) {
  11.     let nameCocktail = input[index];
  12.  
  13.     if (nameCocktail === "Party!") {
  14.         console.log(`We need ${(target - sum).toFixed(2)} leva more.`);
  15.         break;
  16.     }
  17. }
  18.  
  19. let cocktailNum = Number(input[index + 1]);
  20. let totalPrice = (nameCocktail.length) * cocktailNum;
  21.  
  22. if (totalPrice % 2 !== 0) {
  23.     totalPrice = totalPrice * 0.75;
  24. }
  25.  
  26. sum = sum + totalPrice;
  27.  
  28. index += 2;
  29.  
  30. if (sum >= target) {
  31.  
  32.     break;
  33. }
  34.  
  35. if (sum < target) {
  36.  
  37.     console.log(`Club income " + sum.toFixed(2) + " leva.`);
  38.  
  39. } else {
  40.    
  41.     console.log("Target acquired");
  42.    
  43.     console.log("Club income " + sum.toFixed(2) + " leva.");
  44.    
  45.     }
  46.      
  47.    
  48.     }
  49.  
  50. club("500", "Bellini", "6", "Bamboo", "7", "Party!");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement