Switch Statement in JavaScript explained.

Thread
#100DaysOfCode #JavaScript.
✏️ The if-statement causes a branch in the flow of a program's execution and the else-if idiom is used for multi-branches.
What happens when all branches depend on the same value of the expression?

That is when the switch statement comes in.
✏️ A switch statement is a type of selection control mechanism used to allow the value of a variable or expression to change the control flow of program execution.

Flow Diagram.
✏️ A switch statement starts with a variable called the switch vale. Each case indicates a possible value for this variable and the code that run if the variable matches the value.
✏️ Basic syntax.
✏️ Example.
n here is the switch value. if the value entered == 1,
case 1 is executed. if n == 2, then case 3 is executed.
If none matches the cases, then the default case will be executed.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Owireku-Bogyah

Owireku-Bogyah Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @OBogyah

29 Dec
MY THREADS OF THE YEAR.
Wrapping up my 2021 with the best threads. I join tech twitter just 2 months ago and these major threads have helped shape me.

They may not be the best of the best but to me, these people and their amazing threads are the real MVP of my development
🧵🧵🧵
💥 2 months ago I had no idea about web development.
I was depressed trying to figure my life out until I chanced upon this thread.
Although I'm into front-end this is the first thread I read on tech twitter and things haven't been the same.

💥This amazing thread from @VladPasca5 is my ultimate roadmap to a career in web dev.

Read 9 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(