Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function biscuitsFactory(input) {
- let productionPerDay = Number(input.shift());
- let countWorkers = Number(input.shift());
- let productionCompetitor = Number(input.shift());
- let productionFactory = 0;
- for (let i = 0; i < 30; i++) {
- productionFactory += Math.floor(productionPerDay * countWorkers);
- if (i % 3 === 0) {
- productionFactory -= Math.floor(productionPerDay * countWorkers * 0.25);
- }
- }
- let percentage =
- (Math.ceil(productionFactory - productionCompetitor) /
- productionCompetitor) *
- 100;
- console.log(
- `You have produced ${productionFactory} biscuits for the past month.`
- );
- if (productionFactory > productionCompetitor) {
- console.log(`You produce ${percentage.toFixed(2)} percent more biscuits.`);
- } else {
- console.log(
- `You produce ${Math.abs(percentage).toFixed(2)} percent less biscuits.`
- );
- }
- }
- biscuitsFactory([78, 8, 16000]);
- biscuitsFactory([65, 12, 26000]);
Advertisement
Add Comment
Please, Sign In to add comment