+ 3

I need help with my second java script code coach. Please help me!!!

13th Sep 2022, 12:52 PM
Techna๐Ÿ’–๐Ÿ’•๐Ÿ˜Ž
Techna๐Ÿ’–๐Ÿ’•๐Ÿ˜Ž - avatar
15 odpowiedzi
+ 6
for(let x=0 ; ; x -= 2) { i += 1; x += 7; if( x >= depth) break; } Goes like this, better to use while loop.. You're welcome...
13th Sep 2022, 6:56 PM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 6
function main() { var depth = parseInt(readLine(), 10); //your code goes here var i=0 for(x=0; x<="depth"; x+=5) { i+=1 console.log(i) } } Here it is.
13th Sep 2022, 3:17 PM
Techna๐Ÿ’–๐Ÿ’•๐Ÿ˜Ž
Techna๐Ÿ’–๐Ÿ’•๐Ÿ˜Ž - avatar
+ 5
function main() { var depth = parseInt(readLine(), 10); //your code goes here var i=0 for(x=0; x<depth; x+=7) { if (x<depth){ x-=2 i+=1 } else { break } } console.log(i) } Hi, I've tried changing but there is still a little bug in it.
13th Sep 2022, 4:40 PM
Techna๐Ÿ’–๐Ÿ’•๐Ÿ˜Ž
Techna๐Ÿ’–๐Ÿ’•๐Ÿ˜Ž - avatar
+ 4
That's the problem Techna๐Ÿ’–๐Ÿ’•๐Ÿ˜Ž , can you copy your code so far into the code playground and share it here?
13th Sep 2022, 2:35 PM
Ausgrindtube
Ausgrindtube - avatar
+ 3
The snail climbs up 7 feet each day and slips back 2 feet each night. Write a program to calculate how many days will it take the snail to get out of a well with the given depth.
13th Sep 2022, 2:12 PM
Techna๐Ÿ’–๐Ÿ’•๐Ÿ˜Ž
Techna๐Ÿ’–๐Ÿ’•๐Ÿ˜Ž - avatar
+ 3
Thanks so much.
13th Sep 2022, 4:15 PM
Techna๐Ÿ’–๐Ÿ’•๐Ÿ˜Ž
Techna๐Ÿ’–๐Ÿ’•๐Ÿ˜Ž - avatar
+ 3
It worked thank you Jayakrishna
13th Sep 2022, 6:33 PM
Techna๐Ÿ’–๐Ÿ’•๐Ÿ˜Ž
Techna๐Ÿ’–๐Ÿ’•๐Ÿ˜Ž - avatar
+ 2
Where is code? What is the problem?
13th Sep 2022, 1:01 PM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 2
Techna๐Ÿ’–๐Ÿ’•๐Ÿ˜Ž It is javascript code. Not java code. Errors: x is undeclared. anything put in quotes "here" , becomes a string. So "depth" Is a string , not variable so x <= "depth" Is invalid. Use x < depth; No need to output anything inside loop as task asked to output only number of days. Reform these steps : Declare a variable for day before loop. Inside loop start climbing * up 7 so add 7. increment day, if you reach depth stop it; Otherwise down 2 so subtract 2 Repeat this until finish. * Display day value. Understand it and try again....
13th Sep 2022, 4:00 PM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 2
Techna๐Ÿ’–๐Ÿ’•๐Ÿ˜Ž Your code does like this : x = 0 x < depth :: true so x -= 2 => x = -2 without starting done down. (Next adds 7). Which leads wrong result. so First add 7. Then decrement 2 if not reached depth. I += 1 should be in each iteration so irrespective of any condition. Add it outside if block. Better as first line.
13th Sep 2022, 4:53 PM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 2
Hi happy program's day
14th Sep 2022, 4:03 PM
Karun Kambar
+ 1
Very beautiful what a beautiful specialty
14th Sep 2022, 10:35 AM
Mohammed Jamal
Mohammed Jamal - avatar
+ 1
items = ["Rock โœŠ", "Paper ๐Ÿ“ƒ", "Scissor โœ‚๏ธ"] #AI
15th Sep 2022, 2:56 AM
ุนุจุฏู‡ ูุงูŠุฒ
ุนุจุฏู‡ ูุงูŠุฒ - avatar
0
Hello
14th Sep 2022, 6:15 PM
Sonu kumar
Sonu kumar - avatar
0
ุณู„ุงู…
15th Sep 2022, 5:34 AM
Amirali Zahra