The break statement is used to break out of the loop.

Continue is used to skip an iteration in a loop.

The break statement can be used to break out of a loop.

After the break statement breaks out of the loop, the code that follows the loop continues (if any) :

The continue statement interrupts the iteration in the loop, if the specified condition occurs, and continues to the next iteration in the loop.

Code:

<! DOCTYPEhtml>
<html>
	<head>
		<meta charset="utf-8">
		<title>Break and continue</title>
	</head>
	<body>
		<p>The test breaks the loop with break\continue</p>
		<button onclick="myFuntion()">Let me test</button>
		<p id="demo"></p>
		<script>
			function myFuntion(){
				var x="";
				for(i=0; i<10; i++){if(i==5) {// break;
						continue;
						
					}
					x=x+"The current figures are:"+i+"<br/>";
					
				}
				document.getElementById("demo").innerHTML=x;
			}
		</script>
	</body>
</html&
Copy the code