loops problem javascript [solved] | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

loops problem javascript [solved]

Hello, I tried the javascript course, loops part, code project. but my code did not work I don't understand how can I fixed. ------------------------------------------------------------------------------------------------------------- Question: ------------------------------------------------------------------------------------------------------------- The Snail in the Well The snail climbs up 7 feet each day and slips back 2 feet each night. How many days will it take the snail to get out of a well with the given depth? ------------------------------------------------------------------------------------------------------------- my code: ------------------------------------------------------------------------------------------------------------- function main() { var depth = parseInt(readLine(), 10); //your code goes here var day = 0; var snailPosition = 0; var morning = 7; var night = 2; while (True){ snailPosition += morning if(snailPosition >=

15th Sep 2021, 11:40 AM
Hamza Akburak
Hamza Akburak - avatar
1 Answer
+ 1
Hamza Akburak there is no document in nodejs . Use console.log to output the result to standard output display which is usually a terminal.
15th Sep 2021, 1:12 PM
Abhay
Abhay - avatar