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 Respuestas
+ 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);
}