Liliana797979

1_biscuits factory - mid exam - fundamentals

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