JavaScript : Nail in the well | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

JavaScript : Nail in the well

// That's the code i write. But the ''0 < b < 2'' don't work. Help me please. function main() { var depth = parseInt(readLine(), 10); //your code goes here var a = (depth - (depth%5))/5; var b = depth%5; if (b == 0) { day = a ; } else if (0<b<=2) { day = a ; } if (2<b<5) { day = a + 1 ; } console.log (day); }

20th Jul 2021, 12:16 PM
Prosper Zannou HOUNYE
Prosper Zannou HOUNYE - avatar
2 Answers
+ 4
Hi! you have a little broken logic: the snail rises 7 feet up, then you check whether it crawled out of the well or not, and only then, if not, the ons descends 2 feet down.
20th Jul 2021, 12:31 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
Thanks.
20th Jul 2021, 12:33 PM
Prosper Zannou HOUNYE
Prosper Zannou HOUNYE - avatar