Can I return in switch case?

It’s idiomatic to return from case statements, and it’s “unreachable code” noise otherwise. Personally I would remove the returns and keep the breaks. I would use the switch statement to assign a value to a variable. Then return that variable after the switch statement.

Sizin İçin Seçtik  Is switch case better than if else JavaScript?

Leave a Reply

Your email address will not be published. Required fields are marked *