0

Please help me to find the mistake in the code snail in the wall

function main() { var depth = parseInt(readLine(), 10); //your code goes here var climb = 7; var slip = 2; var workday=0; for (i=0;i<=depth;i++){ workday =workday+climb; if(workday >= depth){ break; } workday =workday-slip; if(workday>=depth){ break; } console.log(workday ); } }

21st Feb 2022, 1:07 PM
Achraf Soua
2 Réponses
+ 3
i=1 Also, you need to print how many attempts it made. And, Output should be returned outside loop to get a single value.
21st Feb 2022, 1:30 PM
Simba
Simba - avatar
+ 1
// Try My Code :) let days = 0, result = 0, depth = 31; while (result <= depth) { result += 7; if (result < depth) result -= 2; console.log(`Day ${++days} : `, result); }
21st Feb 2022, 1:55 PM
SoloProg
SoloProg - avatar