
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to come out of a switch case in JavaScript?
To come out of a switch case, use the break statement. The break statements indicate the end of a particular case. If they were omitted, the interpreter would continue executing each statement in each of the following cases.
Example
You can try to run the following example to implement switch-case statement, which uses break statement
<html> <body> <script> var grade='A'; document.write("Entering switch block<br>"); switch (grade) { case 'A': document.write("Excellent<br />"); break; case 'B': document.write("Very good<br />"); break; case 'C': document.write("Passed<br />"); break; case 'D': document.write("Not so good<br />"); break; case 'F': document.write("Failed<br />"); break; default: document.write("Unknown grade<br />") } document.write("Exiting switch block"); </script> </body> </html>
- Related Questions & Answers
- How to use case-insensitive switch-case in JavaScript?
- Switch case calculator in JavaScript
- How to use the break statement to come out of a loop in JavaScript?
- What is Switch...case statement in JavaScript?
- Switch case in Arduino
- How to implement switch-case statement in Kotlin?
- How we can come out of an infinite loop in Python?
- Switch case statement in C
- Switch Case in Python (Replacement)
- String in Switch Case in Java
- How to use an enum with switch case in Java?
- The String in Switch Case in Java
- Explain nested switch case in C language
- Java program to generate a calculator using the switch case
- Java Program to Make a Simple Calculator Using switch...case
Advertisements