at90

Untitled

Jun 7th, 2021
720
356 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function walking(input) {
  2.     let index = 0;
  3.     let steps = 0;
  4.     while (steps < 10000) {
  5.         let nextSteps = input[index++];
  6.         if (nextSteps === 'Going home') {
  7.             steps += Number(input[index]);
  8.             break;
  9.         }
  10.         steps += Number(nextSteps);
  11.     }
  12.  
  13.     if (steps >= 10000) {
  14.         console.log('Goal reached! Good job!');
  15.         console.log(`${steps - 10000} steps over the goal!`);
  16.     } else {
  17.         console.log(`${10000 - steps} more steps to reach goal.`);
  18.     }
  19. }
RAW Paste Data