Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function traveling(input) {
- let index = 0;
- let command = input[index];
- while (command !== 'End') {
- let destination = command;
- index++;
- let budget = Number(input[index]);
- index++;
- let save = 0;
- while (save < budget) {
- let money = Number(input[index]);
- index++;
- save += money;
- }
- console.log(`Going to ${destination}!`);
- command = input[index];
- index++;
- money = Number(input[index]);
- index--;
- }
- }
- traveling(["France",
- "2000",
- "300",
- "300",
- "200",
- "400",
- "190",
- "258",
- "360",
- "Portugal", // 9
- "1450", // 10
- "400", // 11
- "400", // 12
- "200", // 13
- "300", // 14
- "300", // 15
- "Egypt", // 16
- "1900", // 17
- "1000", //18
- "280", //19
- "300",
- "500",
- "End"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement