DEV Community

loading...

Discussion on: Clean up your code by applying these 7 rules ⚡️

Collapse
felipemartins81 profile image
Felipe Martins

Good solution for 'If statements' issue!
What about this way?..

switch (value) {
    case 'duck':
    case 'dog':
    case 'cat':
        // ...
        break;
}
Enter fullscreen mode Exit fullscreen mode
Collapse
joachimzeelmaekers profile image
Joachim Zeelmaekers Author

In this case this would be a good solution, but it gets really big when you have to check 10 options for example! The switch statement is also not available in Python for example.