Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cakeTycoon(input) {
- let plannedCakes = Number(input[0]);
- let cakeFlour = Number(input[1]);
- let flourAvailable = Number(input[2]);
- let truffleCount = Number(input[3]);
- let trufflePrice = Number(input[4]);
- let cakes = parseInt(flourAvailable / cakeFlour);
- if (cakes >= plannedCakes) {
- let cakePrice = truffleCount * trufflePrice / plannedCakes * 1.25;
- console.log(`All products available, price of a cake: ${cakePrice.toFixed(2)}`);
- } else {
- let flourNeeded = plannedCakes * cakeFlour - flourAvailable;
- console.log(`Can make only ${cakes} cakes, need ${flourNeeded.toFixed(2)} kg more flour`);
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement