we use conditions everywhere on our applications whether for state check or rendering some data into the view depending on some parameters. in this...
For further actions, you may consider blocking this person and/or reporting abuse
Just one simple piece of advice: Instead of using 4 spaces for indentation in code snippets for blogs, I think it's better to use 2 spaces as it reduces the need for horizontal scrolling.
Great read. 👌
thanks for this advice 🤍
How about using the tab character? That what it is meant for and every one can set the space to what ever fits best for one.
github.com/gvergnaud/ts-pattern
this is also a good alternative
As always, all gold is in comments :)
will try it thanks 💕
beautiful stuff! rust inspired, perhaps?
Nice read!! a little improvement for the action array.
create a type of actions
then
Voila!
no one should add something weird within 😏
...
that's a great one thanks
My approaching as following
good one too ⭐
didn't expect that anyone would see this post

I think this is not a matter of condition. It's a matter of good practice. Example 1 is easy to understand for beginners, but the other one is good to maintain and easy to extend.
it's a better way to write conditions as you said easy to maintain , extend and debug
Little things like these make you a pro developer. All the best to everyone and thanks to the author for sharing a good and short article.
awesome comment award 🌃⭐
Valuable, Thanks for sharing
Inspiring 👍
This is great!
You get to simplify things further by creating objects with properties that point to specific values instead of checking nonstop for multiple values.
that's exactly it
this is awesome
you are awesome
Thank you 🙏
You're welcome 💕
There is nothing wrong with conditions, you just reshaped the data you are working with
exactly, there is nothing wrong with conditions anyways , it's just a better approach
Amazing tip!
thanks <3
Thank you for posting, I am aspiring to be able to write and understand fluently! Reading these articles from inside perspectives helps tremendously!
glad to hear that 🤍
Really Great Approach, Surely i am going to use in my Project, Awsome Thanks!
that's awesome, have a good one
One more small advice. Just use ENUM for those roles across the project.
imperative vs declarative
Well executed!
thanks 🤍
You are doing great
thanks 💕
Nice one!!!
thanks :)
no thank you. Over-abstractions are harder to maintain when the app grows.
Over-abstractions ?
so when your app grows abstractions is harder to maintain.
Ok
Exactly.
very understandable.
thanks 🤍🔥
Nice code
thanks 🤍
Well explained!
thanks 🤍
Brilliant <3
thanks 🤍
thanks 👌
you are welcome 😌🤍
great
thanks ♥️
Nice. Thank you for this
thanks 🤍😌
Nice explanation.
thanks 🤍
Greate!!!!!
thanks 😌
I like this.
thanks 🤍
Nice
thanks 🤍
Perfect explanation!!!
simple way to do clean code :)
happy to hear that 💕