<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JavaScript break with for loop</title>
</head>
<body>
<pre> <!-- Use pre element for work document.writeln() method -->
<script>
for(var i = 0; i <= 10; i++){
if (i == 5){
document.writeln("terminated, i = 5");
break;
}
document.writeln(i);
}
</script>
</pre>
</body>
</html>