DEV Community

Discussion on: Untangling Nested Code

Collapse
 
itaditya profile image
Aditya Agarwal

Instead of switch statements we can also use objects. The keys act as cases. Now we just have to call decisionObject[case]. It also frees us from break statements

Collapse
 
gonedark profile image
Jason McCreary

Completely agree for simple blocks like the examples. Just remember to use good naming.