Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function travelling(input) {
- //Input
- let command = input.shift();
- let savings = 0;
- while (command != 'End') {
- let destination = command;
- let budgetNeeded = Number(input.shift());
- while (savings < budgetNeeded) {
- savings += Number(input.shift());
- }
- console.log(`Going to ${destination}!`);
- command = input.shift();
- savings = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement