Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function traveling(input) {
- index = 0;
- let destination = input[index];
- index++;
- let currentDestination = "";
- while (destination !== "End") {
- let budget = Number(input[index]);
- index++;
- let totalSum = 0;
- while (totalSum < budget) {
- let currentSum = Number(input[index]);
- index++;
- totalSum += currentSum;
- }
- console.log(`Going to ${destination}!`);
- destination = input[index];
- index++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment