ProdanTenev

Traveling

Mar 2nd, 2022
1,060
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 0.52 KB | None | 0 0
  1. function traveling(input) {
  2.     index = 0;
  3.     let destination = input[index];
  4.     index++;
  5.     let currentDestination = "";
  6.     while (destination !== "End") {
  7.         let budget = Number(input[index]);
  8.         index++;
  9.         let totalSum = 0;
  10.         while (totalSum < budget) {
  11.             let currentSum = Number(input[index]);
  12.             index++;
  13.             totalSum += currentSum;
  14.         }
  15.         console.log(`Going to ${destination}!`);
  16.         destination = input[index];
  17.         index++;
  18.     }      
  19. }
Advertisement
Add Comment
Please, Sign In to add comment