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'); }
0
give a positive ratinggive a negative rating
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'); }
Share on FacebookShare on TwitterShare on LinkedInSend email
1 answer
x
x
2024 AnswerTabsTermsContact us