DEV Community

Diwakar Verma
Diwakar Verma

Posted on

If-Else and Switch Case Statement!

In this article, we’ll talk about what switch case and if-else statements are in JavaScript.

Let’s start with the if-else statement — it’s basically like simple English. Think of it like this:
“If” something happens that matches what I guessed, then do this particular thing.
“Else” (otherwise), just do something else if it didn’t happen.

Now, coming to the switch case statement — it’s just another way of writing multiple if-else statements, but in a cleaner, more readable format.

Anyways, you don’t need to worry much about switch case statements; they’re not used very often in real-world code. But you should definitely focus on understanding if-else statements properly.

Top comments (0)