0
Can anyone help me Javascript challenge I have been solving J's and CSS challenges since. The "Snail in the well" Please
Javascript
6 Respostas
+ 2
Odelola Oluwaseyi .M. Post your attempt first to get help from the community
These Challenges and projects are made to test the users understanding and knowledge .So try doing it yourself for your own progress .
If you want help with the codes , Show your attempt first .
0
function main() {
var depth = parseInt(readLine(), 10);
//your code goes here
var snailclimb = 7;
var snailslip = 2;
var dailysum=0;
var day = 0;
var i = 0;
do{
dailysum += snailclimb;
day++;
dailysum -= snailslip;
console.log(day);
}while(dailysum>depth);
}
0
in 'while' condition you should use 'daily < depth). Otherwise your loop will always iterate only once, since 'dailysum' equals to 0.
0
And don't console.log 'day' on every iteration. Instead, console.log it if the problem condition solution is met.
0
@Artur thank you so much like you are the console. As if you knew that the iteration is going only once. God bless you thank you for the feedback.
0
You should also add:
If(dailysum>=depth)
break;
Before the dailysum-=snailslip;