---
title: "Discussion on \"If-Else or Switch-Case: Which One to Pick?\" | Hashnode"
description: "Discussion on \"If-Else or Switch-Case: Which One to Pick?\". Comparison between if-else and switch-case"
url: "https://hashnode.com/posts/if-else-or-switch-case-which-one-to-pick/618b4475468c06249afc5858"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [If-Else or Switch-Case: Which One to Pick?](https://sumudusiriwardana.hashnode.dev/if-else-or-switch-case-which-one-to-pick?utm_source=hashnode&utm_medium=feed)

Comparison between if-else and switch-case

Nov 10, 2021 · 9 min read · sumudusiriwardana.hashnode.dev  
Updated Nov 19, 2021  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#beginners](https://hashnode.com/tag/beginners)
-   [#newbie](https://hashnode.com/tag/newbie)
-   [#codenewbies](https://hashnode.com/tag/codenewbies)
-   [#programming](https://hashnode.com/tag/programming)

## Written by

[Sumudu Siriwardana](https://hashnode.com/@sumudusiriwardana)

@sumudusiriwardana · Colombo, Sri Lanka

  
[View profile](https://hashnode.com/@sumudusiriwardana)

Project Manager

I'm a Project Manager. I help businesses and teams meet their goals and bring their ingenious ideas to life. While my main focus is on project management, I'm currently learning web development and really enjoying the coding journey.

## Responses 8

Markdown supported · ⌘↵ to post

[Mike Mambwe](https://hashnode.com/@aProdigy)

[Nov 16, 2021](https://hashnode.com/posts/if-else-or-switch-case-which-one-to-pick/618b4475468c06249afc5858/comment/6193818b41b5ce67583aef88)

This was a great breakdown of it all. I hated Switch statements as a beginner, but now everything is second nature thanks to persistence.

[Uma](https://hashnode.com/@Uma14)

[Nov 13, 2021](https://hashnode.com/posts/if-else-or-switch-case-which-one-to-pick/618b4475468c06249afc5858/comment/618fa3db83e4212d6e5785a1)

Have you heard about binary option trading investment where you are going to earn up to $5500 within 48hours kindly inbox Mr mark if you are interested for more details WhatsApp +17575282663

[Akebu](https://hashnode.com/@akebu6)

[Nov 11, 2021](https://hashnode.com/posts/if-else-or-switch-case-which-one-to-pick/618b4475468c06249afc5858/comment/618d49e7f991b025366e2eb6)

The major dilemma that programmers face, well explained. This was so clear and well written Sumudu. I always learn something new from your articles🤗

[Chanel (InstincDev)](https://hashnode.com/@InstincDev)

[Nov 11, 2021](https://hashnode.com/posts/if-else-or-switch-case-which-one-to-pick/618b4475468c06249afc5858/comment/618c7b02468c06249afc70f1)

The comparison chart really helped to make the differences between if...else and switch case clear. Another great article Sumudu!

[Sumudu Siriwardana](https://hashnode.com/@sumudusiriwardana)

[Nov 11, 2021](https://hashnode.com/posts/if-else-or-switch-case-which-one-to-pick/618b4475468c06249afc5858/comment/618c7b02468c06249afc70f1#reply-618cc4ed468c06249afc7560)

Thank you! Glad to hear that, Chanel! 😊

[RAMESH CHANDRA POLA](https://hashnode.com/@Rameshchandra)

[Nov 10, 2021](https://hashnode.com/posts/if-else-or-switch-case-which-one-to-pick/618b4475468c06249afc5858/comment/618bbc38f991b025366e114c)

Love this article. It's a perfect explanation for making the difference between if-else and switch-case. Thanks for sharing.

[Sumudu Siriwardana](https://hashnode.com/@sumudusiriwardana)

[Nov 10, 2021](https://hashnode.com/posts/if-else-or-switch-case-which-one-to-pick/618b4475468c06249afc5858/comment/618bbc38f991b025366e114c#reply-618bcb5ff991b025366e12a7)

Thank you, Ramesh! I'm glad to hear that! 😊

[Ayesha Sahar](https://hashnode.com/@IAyeshaSahar)

[Nov 10, 2021](https://hashnode.com/posts/if-else-or-switch-case-which-one-to-pick/618b4475468c06249afc5858/comment/618b9f85468c06249afc6121)

It's a dilemma that most programmers suffer from but you explained it in a great way!

Thanks for sharing😊

[Sumudu Siriwardana](https://hashnode.com/@sumudusiriwardana)

[Nov 10, 2021](https://hashnode.com/posts/if-else-or-switch-case-which-one-to-pick/618b4475468c06249afc5858/comment/618b9f85468c06249afc6121#reply-618bb586468c06249afc62b3)

Thank you for taking the time to read it and share your feedback, Ayesha! Really appreciate it! 😊

[Daniel Cranney](https://hashnode.com/@danielcranney)

[Nov 10, 2021](https://hashnode.com/posts/if-else-or-switch-case-which-one-to-pick/618b4475468c06249afc5858/comment/618b89ebf991b025366e0c9e)

Love this article, Sumudu! You’ve got a great writing style and this is a question so many developers struggle with.

I’ll certainly be referring back to your article the next time I’m unsure which one to choose!

[Sumudu Siriwardana](https://hashnode.com/@sumudusiriwardana)

[Nov 10, 2021](https://hashnode.com/posts/if-else-or-switch-case-which-one-to-pick/618b4475468c06249afc5858/comment/618b89ebf991b025366e0c9e#reply-618bb55df991b025366e109d)

Thank you so much for your feedback, Daniel! I"m glad to hear it! 😊

[Heaust](https://hashnode.com/@heaust)

[Nov 10, 2021](https://hashnode.com/posts/if-else-or-switch-case-which-one-to-pick/618b4475468c06249afc5858/comment/618b8846468c06249afc5e6e)

Awesome Breakdown!

I once stumbled upon this weird way of doing switch case-y things

```
{
"Condition 1": "Result 1",
"Condition 2": "Result 2"
}[query]
```

Now I always try to do this as a meme xD

[Sumudu Siriwardana](https://hashnode.com/@sumudusiriwardana)

[Nov 10, 2021](https://hashnode.com/posts/if-else-or-switch-case-which-one-to-pick/618b4475468c06249afc5858/comment/618b8846468c06249afc5e6e#reply-618bb510468c06249afc62a6)

This is weird.. I need to check this 😂
