Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function deerOfSanta(input) {
- let days = Number(input[0]);
- let foods = Number(input[1]);
- let deer1 = Number(input[2]);
- let deer2 = Number(input[3]);
- let deer3 = Number(input[4]);
- let neededFood = (deer1 + deer2 + deer3) * days;
- if (foods >= neededFood) {
- console.log(`${Math.floor(foods - neededFood)} kilos of food left.`);
- } else {
- console.log(`${Math.ceil(neededFood - foods)} more kilos of food are needed.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement