for (let i = 0; i <= 3; i++) {
if (i < 3) {
break;
}
console.log(rapperArray[i]);
};
console.log("And if you don't know, now you know.");
When I hit “run” it worked, but the exercise was marked as failed. I do see the “correct” solution, but, what in my code is wrong? I know it would be better to match to BIG since the place in the array can change, but, for the purpose of the exercise I thought this would be okay.
Once I heard that using break, continue, and keywords that would forcibly change the regular logic are not part of good programming practices. Can someone sahre their wisdom on the matter? Thanks!
If they were not part of good practice then why would they exist? We may be able to write code other ways so that we avoid their use, but are they really something to avoid?
Their purpose is simple, based upon a given conditional state, either allow the loop to continue, or force it to terminate immediately. That sounds like an intentional part of the logic, not a forced change of it. They do affect the flow, though.