Liliana797979

Problem 1_2 mid exam

Aug 15th, 2021
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function bisquits(arr) {
  2.   const biquitsPerWorker = Number(arr[0]);
  3.   const workers = Number(arr[1]);
  4.   const toCompare = Number(arr[2]);
  5.   const productionPerDay = biquitsPerWorker * workers;
  6.   const productionFor30Days = (productionPerDay * 20) + Math.floor(productionPerDay * 10 * 0.75);
  7.  
  8.   const dif = productionFor30Days - toCompare;
  9.  
  10.   const persentage = (dif / toCompare) * 100;
  11.   const newPercent = persentage.toFixed(2);
  12.  
  13.   console.log(
  14.     `You have produced ${productionFor30Days} biscuits for the past month.`
  15.   );
  16.   if (productionFor30Days > toCompare) {
  17.     console.log(`You produce ${Math.abs(newPercent)} percent more biscuits.`);
  18.   } else {
  19.     console.log(
  20.       `You produce ${Math.abs(newPercent).toFixed(2)} percent less biscuits.`
  21.     );
  22.   }
  23. }
  24. bisquits(["78",
  25. "8",
  26.  
Advertisement
Add Comment
Please, Sign In to add comment