Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function theBiscuitFactory(arr) {
- let biscuitsPerDay = Number(arr.shift());
- let workersCount = Number(arr.shift());
- let competingFactoryProduction = Number(arr.shift());
- let biscuitsProduced = 0;
- for (let day = 1; day <= 30; day++) {
- let biscuitsDailyProduction = biscuitsPerDay * workersCount;
- if (day % 3 === 0) {
- biscuitsDailyProduction *= 0.75;
- }
- biscuitsProduced += Math.floor(biscuitsDailyProduction);
- }
- console.log(`You have produced ${biscuitsProduced} biscuits for the past month.`);
- let percentage = ((biscuitsProduced - competingFactoryProduction) / competingFactoryProduction) * 100;
- if (percentage > 0) {
- console.log(`You produce ${percentage.toFixed(2)} percent more biscuits.`);
- } else {
- console.log(`You produce ${Math.abs(percentage).toFixed(2)} percent less biscuits.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement