SHARE
TWEET

Untitled

marian74 May 19th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function easterCosinacs(arr) {
  2.  
  3.     let budget = Number(arr[0]);
  4.     let priceForKgFlour = Number(arr[1]);
  5.     let priceForEgs = priceForKgFlour * 0.75;
  6.     let priceForliterMilk = priceForKgFlour * 1.25;
  7.     let priceForQuarterMilk = priceForliterMilk / 4;
  8.     let priseForCosunac = priceForEgs + priceForQuarterMilk + priceForKgFlour;
  9.     let cosunacs = 0;
  10.     let coloredEggs = 0;
  11.  
  12.     while (budget >= priseForCosunac ) {
  13.         cosunacs++;
  14.         budget -= priseForCosunac;
  15.         coloredEggs += 3;
  16.         if (cosunacs % 3 == 0) {
  17.             coloredEggs -= (cosunacs - 2)
  18.         }
  19.     }
  20.    
  21.     console.log(`You made ${cosunacs} cozonacs! Now you have ${coloredEggs} eggs and ${budget.toFixed(2)}BGN left.`);
  22.    
  23. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top