0
How can I stop the FOR count in Jquery? For example:
That code:
for (i = 0; i < 5; i++) {
if (i === 3) { continue; }
text += "The number is " + i + "<br>";
}
Will show the result:
The number is 0
The number is 1
The number is 2
The number is 4
But I would like to display 5 results and not 4. How do I make FOR not increment ++? I’ve tried it this way:
for (i = 0; i < 5; i++) {
if (i === 3) { i--; continue; }
text += "The number is " + i + "<br>";
}
But for some reason it crashes the screen and on the server gives error 503 which means it is consuming a lot of processing.
Play a break instead of continue
– Leonardo Getulio
Your server is Node?
– Leonardo Getulio
If I break him into the loop for good, then we’ll only have the result until "The number is 2"
– Fernando Issler
It’s not Node Leonardo
– Fernando Issler
From an example of how the result you hope to obtain.
– Murilo Portugal
What is the server? pq javascript does not cause 503 on the server, it is processed in the browser.
– Leonardo Getulio
The break will cause it to stop completely the for... it will not pass to the next repeat, will exit and continue the flow of the code.
– Lucas Ayrosa