Important Notice:

Course Content
Switch Statement
0/1
break and continue Statements
0/3
Basic Form Validation in JavaScript
0/1
JavaScript & Angular JS (Chapter- 6) M2-R5.1
About Lesson

Switch Statement:-

                    Switch case statement में expression होता है और उससे related कुछ cases होते है। जो case उस expression या declare किये हुए variable से match होता है तब वो execute होता है। अगर कोई भी case expression से match नहीं होता तो वो default का statement execute करता है। हर statement के बाद break लगाना पड़ता है, इसका मतलब वो उसके पहले का statement ही execute करेगा। अगर break नहीं लगाया जाता तो वो पहला और दूसरा ये दोनों statement को execute करेगा। default case के बाद break नहीं लगाते।

      Syntax:- switch(expression)

      {

                  case value_1;

                              Statement;

                              break;

                  case value_2;

                              Statement;

                              break;

                  default:

                              Statement;

                              }

Question:- 1. Wap to find vowel and consonant.

2. Wap to find day of the given number.

 

Switch Statement:-

                    Switch case statement contains expression and some cases related to it. The case which matches that expression or declared variable is executed. If any case does not match the expression then it executes the default statement. A break has to be put after every statement, which means it will execute only the statement before it. If break is not applied then it will execute both the first and second statements. Do not put break after default case.

      Syntax:- switch(expression)

      {

                  case value_1;

                              Statement;

                              break;

                  case value_2;

                              Statement;

                              break;

                  default:

                              Statement;

                  }

Question:- 1. Wap to find vowel and consonant.

2. Wap to find day of the given number.

error: Content is protected !!