Attempting to crack the 23rd challenge in the SOLOLEARN JavaScript course (known as The Snail in the Well), I came up with this code that worked when the input was 128 but failed when it was 42. What adjustments should be made to ensure the code works successfully for all cases?
function main() {
var depth = parseInt(readLine(), 10);
//your code goes here
let count=0
for( let i=0;i<depth;){
i+=5
count++
}
console.log(count)
}
Link to the Original Challenge:
P.S. You can substitute [parseInt(readLine(), 10);]
with either 42 or 128 and remove the main function to make it compatible with any code editor.