Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pets(input) {
- let day = parseInt(input[0]);
- let foodKg = parseFloat(input[1]);
- let dogKg = parseFloat(input[2]);
- let catKg = parseFloat(input[3]);
- let turtleGr = parseFloat(input[4]);
- let totalKg = dogKg * day + catKg * day + turtleGr / 1000 * day;
- if (foodKg >= totalKg) {
- console.log(`${Math.floor(foodKg - totalKg)} kilos of food left.`);
- } else {
- console.log(`${Math.ceil(totalKg - foodKg)} more kilos of food are needed.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement