0
Hey Guys, Im doing JavaScript Challenge,"Snail's one
The point is, Im stuck.I dunno why I get an error,Just know that the problem it is In the program's end This my code:vec (times ,I mean days..) for(depth,vec=0;depth>0;vec++,depth=depth-5) if(depth<=0){ break; } console.log(vec)
4 Antworten
+ 1
Here is my code.
This may help you.
function main() {
var depth = parseInt(readLine(), 10);
//your code goes here
var climb = 7;
var slip = 2;
var day = 0;
for(workdone=0;workdone<=depth;) {
day = day+1;
workdone = workdone+climb;
if(workdone>=depth){
break;
}
workdone = workdone-slip;
}
console.log(day);
}
+ 1
hi Christian Guerrero
i think the issues is the amount of things in the for loop. try declaring somd variables outside the loop as well as moving depth into the for loop. also maybe use a while like me it’s just easier.
their are other things with your math but you’ll fugure them out
+ 1
Thats incredible Sathe Prerana Satish ,thank you so much ,it is very useful
0
Most welcome 👍