Advertisement
DraconiusNX

Untitled

Sep 29th, 2022
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function club(input) {
  2.     let wantPrice = Number(input[0]);   //500
  3.     let name = input[1];                //Bellini
  4.     ; // 6
  5.  
  6.     let coctailPrice = 0;
  7.     let sum = 0;
  8.     let totalPrice = 0;
  9.  
  10.     for (let i = 1; i < (input.length - 1); i += 2) {
  11.         let name = input[i];
  12.         let countDrinks = Number(input[i + 1])
  13.         coctailPrice = name.length;
  14.         sum = coctailPrice * countDrinks
  15.         if (sum % 2 != 0) {
  16.             sum = sum * 0.75;
  17.         }
  18.         totalPrice += sum
  19.     }
  20.  
  21.    
  22.     let needMoney = wantPrice - totalPrice;
  23.  
  24.     comand = "Party!"
  25.     if (input.includes(comand) && sum < wantPrice) {
  26.         console.log(`We need ${needMoney.toFixed(2)} leva more.`)
  27.     }
  28.     else {
  29.         console.log("Target acquired.")
  30.     }
  31.  
  32.     console.log(`Club income - ${totalPrice.toFixed(2)} leva.`)
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement