0
How can I do the second test of JS? That is about Condition's
I need some help, please
3 ответов
+ 1
The snail in the well?
Hint: You can use a loop to calculate the distance the snail covers each day, and break the loop when it reaches the desired distance.
The hint is pretty straightforward, make your attempt and share your code if you need help.
0
var a = 0;
var day = 1;
do {
day++
a = a + 7 - 2;
}
while (a<=dept);
document.write(day-2);
0
That will not work, since when the input is a multiple of 7, and perhaps at other times, you will reach the target value but the snail will return to the well during the night (-2), making you count one more day...
You have to use that -2 only "if" necessary.
(and I think you should use console.log instead of document.write)