Check if value is not greater / less than zero - Javascript

How to check if value is not greater or less than zero using Javascript ?

I tried to use the following solution for "not greater than zero" condition, but it is not working.

if ( !value>0 && otherValue==1 ) { alert('Ok'); }
23 Oct 2021 at 05:24 PM
0pnshow more
LarsLars
Hi,

To make the "is not greater than zero" condition work correctly in javascript, you have to add brackets (parentheses) there. The code with logical NOT operator used, should look like:

if ( !(value>0) && otherValue==1 ) { alert('Ok'); }
24 Oct 2021 at 10:56 AM
0pnshow more
TimTim
Share on FacebookShare on TwitterShare on LinkedInSend email
Follow us on Facebook & Twitter
2022 AnswerTabsTermsContact us