Advertisement
Guest User

Untitled

a guest
Jul 9th, 2019
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     let items = input.shift().split('|')
  3.     let budjet = +input
  4.     let arr = []
  5.    
  6.     for (let  token of items) {
  7.         let item = token.split('->')
  8.         let name = item[0]
  9.         let price = +item[1]
  10.         let maxPrice = 0
  11.         if (name === "Clothes") {
  12.             maxPrice = 50;
  13.         }
  14.         else if (name === "Shoes") {
  15.             maxPrice = 35;
  16.         }
  17.         else if (name === "Accessories") {
  18.             maxPrice = 20.5;
  19.         }
  20.         if (price <= budjet && price <= maxPrice) {
  21.             budjet -= price
  22.             arr.push(+((price * 1.4).toFixed(2)))
  23.         }
  24.  
  25.     }
  26.     console.log(arr.join(' '))
  27.     let sumWithProfit=0
  28.     for(let el of arr){
  29.         sumWithProfit+=el
  30.     }
  31.    
  32.     let profit = (sumWithProfit - sumWithProfit / 1.4).toFixed(2);
  33.     let sum=budjet+sumWithProfit
  34.     console.log(`Profit: ${profit}`)
  35.    
  36.     if (sum >= 150)
  37.     {
  38.         console.log("Hello, France!");
  39.     }
  40.     else
  41.     {
  42.         console.log("Time to go.");
  43.     }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement