Advertisement
Liliana797979

viarno reshenie na care of puppy

Feb 1st, 2021
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.   let remainingFood = Number(input.shift()) * 1000;
  3.  
  4.   let command;
  5.   while ((command = input.shift()) !== 'Adopted') {
  6.     let eaten = Number(command);
  7.     remainingFood -= eaten;
  8.   }
  9.   if (remainingFood >= 0) {
  10.     console.log(`Food is enough! Leftovers: ${remainingFood} grams.`);
  11.   } else {
  12.     console.log(`Food is not enough. You need ${-remainingFood} grams more.`);
  13.   }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement