Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function walking (input) {
- let steps = input.shift();
- let goalToReach = 10000;
- let sCount = 0;
- let result = 10000;
- while(steps < goalToReach) {
- let text = Number(steps);
- sCount += text;
- steps = input.shift();
- }
- if(steps == 'Going home') {
- result -= sCount
- }
- if(sCount < goalToReach) {
- console.log(`${result} more steps to reach goal.`)
- } else {
- console.log(`Goal reached! Good job!`)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement