DEV Community

Discussion on: Switch statements in javascript – How to refactor?

Collapse
 
jonrandy profile image
Jon Randy 🎖️ • Edited

Example 1 would be simpler with an array.

Also, you can add js after the opening backticks on the code blocks to switch on syntax highlighting

Collapse
 
ajayv1 profile image
Ajay Kumar Verma

Yes @jonrandy As array is also an object in javascript so it would also work the same. Thanks for the suggestion.