āœ”||šŸ¤¢ Commit or Vomit | Switch(true)

jmdejager

šŸ¤šŸ„‡ Jasper de Jager

Posted on April 2, 2021

āœ”||šŸ¤¢ Commit or Vomit | Switch(true)

In my recent post I questioned the use of a switch instead of an if else statement. This gave me the idea of an recurring item for dev.to: Commit or Vomit! Would you commit this code or not.

It's going to be code snippets that are going to be evaluated here. Not posts because I don't want people to feel/be judged by this, only code!

So this first āœ”||šŸ¤¢ is from the post that started it all.


switch(true){
    case userMissedAppointment:
        return 'nope';
    case userHasAngularExperience:
    case userHasReactExperience:
    case userHasVueExperience && userCanStartInstantly:
        return 'hire';
    default:
        return 'maybe'
}
Enter fullscreen mode Exit fullscreen mode

This is just an example but the question is about the switch(true). What do you think? āœ”||šŸ¤¢

ā¤: Commit
šŸ·: Vomit (we all know unicorns don't vomit)
šŸ¦„: Like your post please continue this series!

Looking forward to your reactions! šŸ˜Ž

šŸ’– šŸ’Ŗ šŸ™… šŸš©
jmdejager
šŸ¤šŸ„‡ Jasper de Jager

Posted on April 2, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related