pacho_the_python

Untitled

Jun 18th, 2023
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function theBiscuitFactory(arr) {
  2.     let biscuitsFromOneWorker = Number(arr[0]);
  3.     let numberOfWorker = Number(arr[1]);
  4.     let competitors = Number(arr[2]);
  5.     let allBiscuitsPerDay = biscuitsFromOneWorker * numberOfWorker;
  6.     let sum = 0;
  7.     for (let i = 1; i <= 30; i++) {
  8.         if (i % 3 === 0) {
  9.             sum += (allBiscuitsPerDay * 0.75);
  10.             sum = Math.floor(sum);
  11.         } else {
  12.             sum += allBiscuitsPerDay;
  13.             sum = Math.floor(sum);
  14.         }
  15.     }
  16.     let diff = Math.abs(sum - competitors);
  17.     let percentage = (diff / competitors) * 100;
  18.     console.log(`You have produced ${sum} biscuits for the past month.`);
  19.     if (sum > competitors) {
  20.         console.log(`You produce ${percentage.toFixed(2)} percent more biscuits.`)
  21.     } else {
  22.         console.log(`You produce ${percentage.toFixed(2)} percent less biscuits.`)
  23.     }
  24. }
  25. theBiscuitFactory([
  26.     "78",
  27.     "8",
  28.     "16000"
  29. ]);
  30. theBiscuitFactory(["65",
  31.     "12",
  32.     "26000"
  33. ]);
  34. theBiscuitFactory(["163",
  35.     "16",
  36.     "67020"
  37. ]);
Add Comment
Please, Sign In to add comment