How To Use Continue Statement Using JavaScript?


Share:
Published By: Admin, Published On: Nov 20, 2021, Category: Javascript


Hello Friends,

Now let's see example of how to use continue statement example. We will check use of continue statement using javascript. This is a short guide on use continue statement in javascript. Let's get started with how to use continue statement in javascript.

Here i will give you many example how to use continue statement using javascript.

Example : 1
<!DOCTYPE html> 
<html> 
	<head>
		<title>How To Use Continue Statement Using JavaScript? - MyWebtuts.com</title> 
	</head> 
	<body> 
		<h3>How To Use Continue Statement Using JavaScript? - MyWebtuts.com</h3>
		<h3> Here, you can see that "a == 5" is skipped. </h3> 
		<p id = "tst"></p> 
		<script> 
			var res = "";
			var a1;
			for (a1 = 1; a1 <=7; a1++) {
				if (a1 == 5) {
					continue;
				}
				res += "The value of a1 is : " + a1 + "<br>";
			}
			document.getElementById("tst").innerHTML = res;
		</script> 
	</body> 
</html>  
Output :
Here, you can see that "a == 5" is skipped.
The value of a1 is : 1
The value of a1 is : 2
The value of a1 is : 3
The value of a1 is : 4
The value of a1 is : 6
The value of a1 is : 7
Example : 2
<!DOCTYPE html>
<html>
    <head>
        <title>How To Use Continue Statement Using JavaScript? - MyWebtuts.com</title>
    </head>
    <body>
        <h3>How To Use Continue Statement Using JavaScript? - MyWebtuts.com</h3>
        <h3> You can see that the arrray values "Php" and "JQuery" are skipped. </h3>
        <script>
            var subjects = ["Laravel", "JavaScript", "Php", "JQuery", "BootStrap"];
            var a1 = 0;
            var res = "";
            while(a1 < subjects.length){

                if (subjects[a1] == "Php" || subjects[a1] == "JQuery") {
                    a1++;
                    continue;
                }
                res = "";
                res += subjects[a1] + "<br>";
                a1++;
                document.write(res);
            }
        </script>
    </body>
</html>  
Output :
You can see that the arrray values "Php" and "JQuery" are skipped.
Laravel
JavaScript
BootStrap

It will help you...

Share: