Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis0
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 Respostas
+ 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);
}