0
JavaScript Trip planner âSnail in the Wellâ
I canât seem TO WORK THIS OUT. THIS IS WHAT IâVE GOT SO FAR, BUT IT DOESNâT LIKE IT. DOES ANYONE KNOW HOW TO FIX THIS PLEASE? ALSO, IâM SORRY ABOUT THE CAPITALS, I DONâT KNOW WHY, BUT IT WONT LET ME TYPE LOWERCASE. function main() { var depth = parseInt(readLine(), 10); var depth = depth; var distance = 0; var days = 0; if (depth > distance){ days++; distance += 7; if (depth > distance){ distance -= 2; } else{ console.log(days); } }else{ console.log(days); } }
2 Answers
+ 1
Shania Try this.
while(true) {
distance += 7;
days++;
if(depth >= distance) {
break;
}
distance -= 2;
}
console.log(days);
0
Thank you so much for responding I Am Groot ! . I couldnât have done it without you! This is my finished result:
function main() {
var depth = parseInt(readLine(), 10);
//your code goes here
var depth = depth;
var distance = 0;
var days = 0;
while(depth >= distance){
distance += 7;
days++;
if(depth <= distance){
break;
}
distance -= 2;
}
console.log(days);
}