0
Snail in the wall (js)
I'm completely beginner in js and I'm trying to solve thos code chalange: The chalange is basically about a snail climbing 7 feet up the wall each day and 2 feet down each night. And I should output the number of days it takes for snail to climb out of the wall completely. I wrote this code but I don't know what's is the problem with it and why it doesn't work. function main() { var depth = parseInt(readLine(), 10); //your code goes here var day = 0; do depth -= 7 while (depth >= 0){ depth += 2 day++ } console.log(day) } I would appreciate if I could get some help about this.
8 Answers
+ 3
The do part is wrong. Review that first.
+ 2
Can you share your updated code?
+ 2
Ok, I don't see the semi-colon...
Check the logic. What does your while condition say?
You have a while code statement but your do statement executes until your while condition is met (if you removed the curly brackets).
+ 2
Great work!
And no worries about the help. That's what the community is here for.
+ 1
Ausgrindtube oh I got it now. Sorry I forgot to add semi colon to my previous message. Thank you so much for the help
+ 1
Ausgrindtube â¤ď¸â¤ď¸đ
0
Ausgrindtube thank you for your respons
I read js course about do while again and checked some examples provided by other people. I undrestood I missed a semicolon after do code block but after adding it, it still doesn't work
0
Ausgrindtube
I just changed the do block
do{
depth -= 7
}