0
Hi I'm having a problem with Javascript, I'm currently learning js here and I'm stuck on the conditionals and loops code project
Please anyone who has solved it and understands it should please help
15 Respostas
+ 2
Your try?
+ 1
Thats how i did it:
function main() {
var depth = parseInt(readLine(), 10);
var climp = 0
var day = 0
var night = 0
for (; depth > climp;){
climp = climp + 7;
day = day + 1
if(climp >= depth){
console.log(day)
break;
}
else{
climp = climp -2;
night = night +1;
}
}
}
0
do {snailProgress +=5}
While{snailProgress <=depth}
0
Pls add full code link by saving it playground..
other wise I have to guess a lot...
0
I know I'm wrong but what I don't know is what to do now
0
It climbs 7 steps and only falls 2 step back if not reached
0
Yes it climbs 7ft a day and falls back 2ft in the night
So total is 5ft in a day
That's the snail's progress
But I was asked for the days taken for the snail to leave the well of unknown depth
0
Can't send the playground link cos I don't see the option there but it's a code project in the Javascript conditionals and loops lesson
It's at the end of the lesson
0
What if last, it reached in day by climbing 7fts..? You don't need to subtract 2 feets. If you subtract then it count as one more day.. Understood?
0
Yeah I understand what you're saying so I won't base my day on the number of feet climbed
So which parameter do I use?
0
No. It's based on feets only.. But add 7ft, only subtract 2 if not reached depth, day count+1.
You can copy paste your code or share link saved copy-paste..
edit:
Samuel Godswill Eric
hope these helps...
https://www.sololearn.com/discuss/2951346/?ref=app
https://www.sololearn.com/discuss/2615972/?ref=app
0
Thanks a lot
0
No.. he doesn't have to
0
I understand it now thanks
- 2
You must learn Java first you can fine the basek there