Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cardio(input){
- let steps=0
- index=0
- let comand=input[index];
- index++
- while(steps<=10000){
- if(comand ==="Going home"){
- steps+=Number (input[index]);
- index++
- break;
- }
- let temp=Number(comand)
- steps+=temp
- comand=input[index]
- index++
- }
- if(steps >=10000){
- let diff=steps - 10000
- console.log( `Goal reached! Good job!`)
- console.log(`${diff} steps over the goal!`)
- }else{
- console.log(`${10000-steps} more steps to reach goal.`)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement