Advertisement
ExGiX

asd

Mar 16th, 2020
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. function walking (input) {
  2.  
  3. let steps = input.shift();
  4. let goalToReach = 10000;
  5. let sCount = 0;
  6. let result = 10000;
  7.  
  8.  
  9. while(steps < goalToReach) {
  10.  
  11. let text = Number(steps);
  12.  
  13. sCount += text;
  14.  
  15. steps = input.shift();
  16.  
  17. }
  18.  
  19. if(steps == 'Going home') {
  20. result -= sCount
  21. }
  22.  
  23. if(sCount < goalToReach) {
  24. console.log(`${result} more steps to reach goal.`)
  25. } else {
  26.  
  27. console.log(`Goal reached! Good job!`)
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement