Advertisement
vladovip

Biscuits Factory

Feb 20th, 2022
759
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function biscuitFactory(input) {
  2.   let buisciutsProducedPerDayWorker = input.shift();
  3.   let countWorkersInFactory = input.shift();
  4.   let numberOfCompetengBiscuits30days = input.shift();
  5.   let days = 1;
  6.   let totalMyProdcution = 0;
  7.  
  8.   while (days <= 30) {
  9.     if (days % 3 !== 0) {
  10.       totalMyProdcution += Math.floor(
  11.         buisciutsProducedPerDayWorker * countWorkersInFactory
  12.       );
  13.     }
  14.     if (days % 3 === 0) {
  15.       totalMyProdcution += Math.floor(
  16.         buisciutsProducedPerDayWorker * countWorkersInFactory * 0.75
  17.       );
  18.     }
  19.     days++;
  20.   }
  21.   console.log(
  22.     `You have produced ${totalMyProdcution} biscuits for the past month.`
  23.   );
  24.  
  25.   let differenceBetweenFactories = totalMyProdcution - numberOfCompetengBiscuits30days;
  26.   let percentage = 0;
  27.  
  28.  
  29.   if (differenceBetweenFactories > 0) {
  30.     percentage = (
  31.       (differenceBetweenFactories / numberOfCompetengBiscuits30days) *100).toFixed(2);
  32.       console.log(`You produce ${percentage} percent more biscuits.`);
  33.   }
  34.   else if (differenceBetweenFactories < 0) {
  35.     percentage = (((numberOfCompetengBiscuits30days-totalMyProdcution) / numberOfCompetengBiscuits30days) *100).toFixed(2);
  36.     console.log(`You produce ${percentage} percent less biscuits.`);
  37.   }
  38. }
  39.  
  40.  biscuitFactory([78, 8, 16000]);
  41.  biscuitFactory([65, 12, 26000]);
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement