I have a student that is creating a number guessing game and wants to use a break statement, but I noticed there is not a block for that in app lab. What are some solutions to use instead of a break statement?
You can use a while loop and set the while loop condition to false when the guess is correct.
var isCorrect = false
while (!isCorrect) {
.
.
if (guess == correct answer)
isCorrect = true;
...
}
I have a few students that are typing in break and the code works. I’m suspicious because I’ve never talked about break and continue, but a few kids seem to know quite a bit about it.