Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Break and Continue in JavaScript

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<button onclick="breakStatementExample()" id="btnClick">Click</button>
<script>
function breakStatementExample()
{
var x;
for ( x=0; x<=15; x++) {
if(x==10)
{
break;
}
if (x === 0)
{
document.write(x +" "+ "is"+" " + "an" + " " + "even number"+ "<br>");
}
else if (x % 2 === 0) {
document.write(x + " "+ "is"+ " " + "an" + " " + "even number"+ "<br>");
}
else {
document.write(x + " "+ "is"+ " " + "a" + " " + "odd number"+ "<br>" );
}
}
}
</script>
</body>
</html>
Source by www.enjoysharepoint.com #
 
PREVIOUS NEXT
Tagged: #Break #Continue #JavaScript
ADD COMMENT
Topic
Name
3+8 =