JavaScript break statement is used to jump out of loop. See the code snippet:
<!DOCTYPE html>
<html>
<head>
<title>Welcome to LearnKode - A code learning platform</title>
</head>
<body>
<p>A loop with a break statement.</p>
<p id="sample"></p>
<script>
var text = "";
var i;
for (i = 0; i < 10; i++) {
if (i == 2) { break; }
text += i + "<br>";
}
document.getElementById("sample").innerHTML = text;
</script>
</body>
</html>