Advertisement
PavelIvanov

Untitled

May 23rd, 2020
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. function solve(input) {
  2. let totalSteps = 0;
  3. while (totalSteps <= 10000) {
  4. let steps = input.shift();
  5. if (steps=='Going home') {
  6. let stepsToHome=Number(input.shift());
  7. totalSteps+=stepsToHome;
  8. break;
  9. }
  10. let currentSteps=Number(steps);
  11. totalSteps += currentSteps;
  12.  
  13. }
  14. if (totalSteps<10000) {
  15. console.log(`${10000 - totalSteps} more steps to reach goal.`);
  16. } else {
  17. console.log('Goal reached! Good job!');
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement