- 3

Help

function main() { var depth = parseInt(readLine(), 10); //your code goes here var depth = } https://code.sololearn.com/czR3FUuWrPUj/?ref=app

24th Sep 2022, 9:20 PM
Emmanuel Pena
15 Answers
+ 3
How about your attempt?
24th Sep 2022, 9:29 PM
JaScript
JaScript - avatar
+ 1
Emmanuel Pena And stop posting new comments with copies of the code. This makes it harder and harder to find information among too many comments.
25th Sep 2022, 9:05 PM
Emerson Prado
Emerson Prado - avatar
+ 1
OK. Some questions: 1. What is the purpose of variable "depth"? The code gets it from the user, but never uses it again. 2. Why do you initialize variable "day" with 7? 3. What is the logic behind the series of "if"s? And some recommendations: 1. Review the "if" statement syntax. 2. Take a good read on loops. No hurry - I mean a good read indeed.
26th Sep 2022, 5:16 AM
Emerson Prado
Emerson Prado - avatar
0
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? Sample Input: 31 Sample Output: 6 Explanation: Let's break down the distance the snail covers each day: Day 1: 7-2=5 Day 2: 5+7-2=10 Day 3: 10+7-2=15 Day 4: 15+7-2=20 Day 5: 20+7-2=25 Day 6: 25+7=32 So, on Day 6 the snail will reach 32 feet and get out of the well at day, without slipping back that night.
24th Sep 2022, 9:21 PM
Emmanuel Pena
0
function main() { var depth = parseInt(readLine(), 10); //your code goes here var day =7 if(day 1, 7-2=5){ break; { if (day 2, 5+7-2){ break;{ if(day 3 12+7-2){ break; if (day 4 19+7-2){ break;{ if(day 5 26+7-2){ break;{ console.log (day) }
24th Sep 2022, 10:20 PM
Emmanuel Pena
0
This doesn't seem valid syntax. Also, do you notice how the steps repeat themselves? Shouldn't them be in a loop instead? Before anything else, pls add two important fixes to the question itself: 1. Replace all tags with a single one with the language name 2. Put your started code in Code Playground and add a link to it in the question description - use "+" button With these simple actions, we'll fix the code step by step.
25th Sep 2022, 2:07 AM
Emerson Prado
Emerson Prado - avatar
0
I dont know how share a link
25th Sep 2022, 2:45 AM
Emmanuel Pena
0
??
25th Sep 2022, 2:17 PM
Emmanuel Pena
0
function main() { var depth = parseInt(readLine(), 10); //your code goes here var day =7 if(day 1, 7-2=5){ break; { if (day 2, 5+7-2=10){ break;{ if(day 3 12+7-2=17){ break; if (day 4 19+7-2=24){ break;{ if(day 5 26+7=33){ break;{ console.log (day) }
25th Sep 2022, 3:28 PM
Emmanuel Pena
0
Anybody could help ?
25th Sep 2022, 8:38 PM
Emmanuel Pena
0
Emmanuel Pena Go to code section, paste your code and save as public. Then, come back to the question, tap the 3 dots, then Edit. Go to the question description, tap "+", select "Code", then choose the one you saved.
25th Sep 2022, 9:03 PM
Emerson Prado
Emerson Prado - avatar
0
Sorry wont happen again , but i did what you said take a look
25th Sep 2022, 9:31 PM
Emmanuel Pena
0
Emmanuel Pena You can check this code here. https://code.sololearn.com/Wk2yexjwquPk/?ref=app
26th Sep 2022, 3:03 PM
Shree Kumar
0
Thank u so much !!
26th Sep 2022, 7:51 PM
Emmanuel Pena
0
Shree Kumar Pls avoid giving finished code as answer, because it makes the OP skip the most important part of learning process. Prefer giving hints for the OP to find the solution.
27th Sep 2022, 1:54 AM
Emerson Prado
Emerson Prado - avatar