Let's say I have this for
loop that works based on my array
name:
var nomes = ["Nome 1", "Nome 2", "Nome 3"];
for(i = 0; i <= 2; i++) {
if(nomes[i] == "Nome 2") {
console.log(nomes[i]);
console.log("Stop!");
break;
}
}
I'm stopping it by making use of break
.
Is this a good way to stop a loop
?