Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. function bisquitsFactory(
  2. bisquitsPerDayPerWorker,
  3. workers,
  4. competeFactoryCapacityPer30Days
  5. ) {
  6. let bisquitsSum = 0;
  7.  
  8. for (let day = 1; day <= 30; day++) {
  9. let bisquitsPerDay = parseInt(bisquitsPerDayPerWorker * workers);
  10. if (day % 3 === 0) {
  11. bisquitsPerDay = parseInt(bisquitsPerDay * 0.75);
  12. }
  13. bisquitsSum += bisquitsPerDay;
  14. }
  15.  
  16. console.log(`You have produced ${bisquitsSum} biscuits for the past month.`);
  17.  
  18. let diff = Math.abs(competeFactoryCapacityPer30Days - bisquitsSum);
  19. let percentage = ((diff / competeFactoryCapacityPer30Days) * 100).toFixed(2);
  20.  
  21. if (competeFactoryCapacityPer30Days > bisquitsSum) {
  22. console.log(`You produce ${percentage} percent less biscuits.`);
  23. } else {
  24. console.log(`You produce ${percentage} percent more biscuits.`);
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement