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