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