Advertisement
BbJLeB

05.traveling

Nov 19th, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function traveling (input){
  2.     let destination = "";
  3.     money = 0;//1 място
  4.  
  5.     while (true){
  6.         destination = input.shift();
  7.         if (destination == "End"){
  8.             break;
  9.         }
  10.         let neededMoney = Number(input.shift());//2, 3 място
  11.         let savedMoney = 0;//4 място
  12.  
  13.         while (savedMoney < neededMoney){
  14.             money = Number(input.shift())//5 място
  15.             savedMoney += money;
  16.         }
  17.         console.log(`Going to ${destination}!`);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement