Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. function solve(input) {
  2. let command = input.shift();
  3.  
  4. let destination = '';
  5.  
  6. while (command !== "End") {
  7. if (!(command >= 0)) {
  8. destination = command;
  9. command = input.shift();
  10. }
  11.  
  12. else {
  13. let budget = Number(command);
  14. command = input.shift();
  15.  
  16. while (!(isNaN(command))) {
  17. let money = Number(command);
  18. if (isNaN(money)) {
  19. break;
  20. }
  21. command = input.shift();
  22. }
  23.  
  24. console.log(`Going to ${destination}!`)
  25. }
  26.  
  27. }
  28. }
  29.  
  30. solve(["Greece",
  31. 1000,
  32. 200,
  33. 200,
  34. 300,
  35. 100,
  36. 150,
  37. 240,
  38. "Spain",
  39. 1200,
  40. 300,
  41. 500,
  42. 193,
  43. 423,
  44. "End"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement