Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function catFood(input) {
- let num = Number(input.shift());
- let firstGroup = 0;
- let secondGroup = 0;
- let thirdGroup = 0;
- let totalFood = 0;
- for (let i = 0; i < num; i++) {
- let food = Number(input.shift());
- totalFood += food;
- if (food >= 100 && food < 200) {
- firstGroup++;
- } else if (food >= 200 && food < 300) {
- secondGroup++;
- } else if (food >= 300 && food < 400) {
- thirdGroup++;
- }
- }
- let price = totalFood * 0.01245;
- console.log(`Group 1: ${firstGroup} cats.`);
- console.log(`Group 2: ${secondGroup} cats.`);
- console.log(`Group 3: ${thirdGroup} cats.`);
- console.log(`Price for food per day: ${price.toFixed(2)} lv.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement