Learning JS Course @Sololearn - Day28

Photo by Andrew Neel on Unsplash

Learning JS Course @Sololearn - Day28

·

2 min read

Today #day28 of #100daysofcode, I have completed 2 lessons: 17,18 in module 3 and a practice program in JS. @Sololearn

Conditionals and Loops

The switch Statement

  • test multiple conditions.
  • to perform different actions based on different conditions.
  • syntax: switch (expression) { case n1: statements break; case n2: statements break; default: statements }

  • In a way: Switch stands for 'if' Case stands for 'else if' Default stands for 'else'

The break Keyword

  • to come out of the code execution loop

The default Keyword

  • default statement is mandatory this will be executed when there is no match.
  • there is no break keyword for default it is the last case which will be executed if there is no match.

Loops

  • when you want to execute a block of code repeatedly, you use loops.
  • JavaScript hash 3 types of loops they are for loop while loop command do while loop.

The for loop

  • syntax: for (statement 1; statement 2; statement 3) { code block to be executed }
  • the classic for loop consists of 3 components or statements.
  • statement one his optional, statement 2 is optional but you have to put break in the blockcode.

Images:

  • 6. day28 module 3-lesson17 completed.png
  • 11. day28 3.18 lesson completed.png

Conclusion

  • The switch Statement
  • The for loop
  • code
  • quiz

My Code:

  • 3. day28 prog prob.png
  • 8. day28 quiz6.png

References Sololearn

Author: Dheeraj.y

Connect with me:

Did you find this article valuable?

Support dheerajy blog by becoming a sponsor. Any amount is appreciated!