Задача walking
линк:https://judge.softuni.bg/Contests/Compete/Index/1014#4
това е кода ми:
function walking(input) {
let currentsteps=Number(input.shift);
let sumsteps=0;
let isgoal=false;
while (sumsteps<10000) {
if (currentsteps=="Going Home") {
currentsteps=Number(input.shift());
sumsteps+=currentsteps;
if (sumsteps>=10000) {
isgoal=true;
}
break;
}
currentsteps=Number(currentsteps);
sumsteps+=currentsteps;
currentsteps=input.shift();
}
if (isgoal || sumsteps >= 10000) {
console.log('Goal reached! Good job!')
} else {
let diff=10000-sumsteps;
console.log(`${diff} more steps to reach goal.`)
}
}