Sitemap
Web Designing Theory

Web Designing Theory

Sharing interesting, dependable web design and technology tutorials. Specializing in HTML and CSS. From BCA to MCA—learn front-end tech with us!

break statement in javascript

2 min readAug 2, 2024

--

Press enter or click to view image in full size
Photo by AltumCode on Unsplash

What is the Break Statement JavaScript.

Press enter or click to view image in full size

The break statement ends a loop or a switch. It emerges from the switch block in a switch. This puts an end to the switch’s internal code execution. When a loop is encountered, it exits the loop and resumes running the code.

Break Statement syntax :-

Syntax :-

break;

OR

break label;

FlowChart :-

break statement in javascript example:-

Program :-

print the value of if use break statement

for(let i=1;i<=7;i++)

{

if(i==6)

{

break;

}

console.log(i);

}

Output :-

print the value of z while loop use break statement

Program :-

let z=0;

while(z<15)

{

if(z===12)

{

break;

}

console.log(z);

z++

}

Get Web Designing Theory’s stories in your inbox

Join Medium for free to get updates from this writer.

console.log(“loop terminated.”);

output:-

print the value of day use switch case usebreak statement

Program:-

let day =5;

switch(day)

{

case 1:

console.log(‘Sunday’);

break;

case 2:

console.log(‘Monday’);

break;

case 3:

console.log(‘Tuesday’);

break;

case 4:

console.log(‘Wednesday’);

break;

case 5 :

console.log(‘Thursday’);

break;

case 6:

console.log(‘Friday’);

break;

case 7:

console.log(‘Saturday’);

break;

default:

console.log(‘invalid day’)

}

Output:-

Related Post :-

JavaScript if.. else statement

JavaScript switch statement

JavaScript do .. while loop

--

--

Web Designing Theory
Web Designing Theory

Sharing interesting, dependable web design and technology tutorials. Specializing in HTML and CSS. From BCA to MCA—learn front-end tech with us!