break and continue. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

break and continue.

when we use break and continue statement .sometimes when we use var and add it to another for loops how to the machine if you understand me and if you know it send me the answer. The code is like this. var n=0; //n equal to zero; for(i=4;i<8;i++){ if(i==6){ continue; } n+=i; } document.write(n+"<br/>"); if u can answer me as fast as u can.

25th Oct 2020, 8:25 PM
justkidus
justkidus - avatar
1 Answer
0
Continue cause to skip next statements of loop for current iteration. For ex: in your code when i==6 then it executes continue means next n+=i is not executed for i=6 iteration continue with i=7 Break cause loop to exit. For ex: if you write break instead of continue then loop stops there and comes out to next statement i.e document.write(n);
25th Oct 2020, 9:26 PM
Jayakrishna 🇮🇳