Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function catShelter(input) {
- let food = Number(input.shift()) * 1000;
- let command = input.shift();
- while (command !== "Adopted") {
- food -= Number(command);
- command = input.shift();
- }
- if (food >= 0) {
- console.log(`Food is enough! Leftovers: ${food} grams.`);
- } else {
- console.log(`Food is not enough. You need ${Math.abs(food)} grams more.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement