Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let command = input.shift();
- let destination = '';
- while (command !== "End") {
- if (!(command >= 0)) {
- destination = command;
- command = input.shift();
- }
- else {
- let budget = Number(command);
- command = input.shift();
- while (!(isNaN(command))) {
- let money = Number(command);
- if (isNaN(money)) {
- break;
- }
- command = input.shift();
- }
- console.log(`Going to ${destination}!`)
- }
- }
- }
- solve(["Greece",
- 1000,
- 200,
- 200,
- 300,
- 100,
- 150,
- 240,
- "Spain",
- 1200,
- 300,
- 500,
- 193,
- 423,
- "End"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement