0
My code is simple. 1 test case is running. The other one is not showing any output. Please help please 🥺🥺
function main() { var depth = parseInt(readLine(), 10); var d=1; climb=0;fell=0; for(d=1;d<=depth;d++) { { climb =fell +7; fell=climb-2; } if(climb==depth) { console.log(d); } } } This isy code. Test case : 128 as input.. No output showing. Why?? Please help.
2 ответов
0
Hi, your code will print anything only then variable climb is equal to number that you entered(variable depth) ...
0
Try debugging you code by printing the values of your variables before the if statement:
climb = fell + 7;
fell = climb - 2;
console.log(climb)
console.log(fell)
console.log("------")
This way you can see what is happening in more detail. allowing you to see why climb is never equal to depth.
Hopefully this will help you to figure out the problem. Have fun coding :)