Skip to content
Advertisement

shorten if conditions in js

I want to shorten the conditions of a javascript if but I don’t know how I can achieve it

code:

JavaScript

I have the conditions defined in this way:

JavaScript

I appreciate any help! 🙂

Advertisement

Answer

You can remove all unnecessary parenthesis in your if condition:

JavaScript

Other than that, there’s not really a clean, readable way to shorten your code.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement