+ 2

Can someone pls explain whats wrong with this code?

function main() { var depth = parseInt(readLine(), 10); //your code goes here var up=7-2; var hg=0; var days=0; do{ hg=hg+up; days=days+1; if(hg>depth){ break; } } while (hg<=depth ); console.log(days); } Above is the Js project from loops,the answer should be 8,but it shows 9.

3rd Dec 2021, 4:38 PM
KADHM
KADHM - avatar
4 Antworten
+ 2
3rd Dec 2021, 5:52 PM
Jayakrishna 🇮🇳
+ 2
// I've fixed them below do { hg+=up; if(hg>depth) break; days++; } while (hg<=depth);
3rd Dec 2021, 11:16 PM
SoloProg
SoloProg - avatar
+ 2
Jayakrishna🇮🇳 thank you for ur support .
4th Dec 2021, 4:23 AM
KADHM
KADHM - avatar
+ 1
SoloProg thank you for ur support too.
4th Dec 2021, 4:24 AM
KADHM
KADHM - avatar