checking if decimal is negative in javascript

0 votes
asked Mar 7 by anonymous
edited Mar 7
I am new in programming , i want to know how to check if decimal is negative using javascript.

Say e.g.

var x=-0.1298

expected result negative

var x=0.6543

expected result positive

1 Answer

0 votes
answered Mar 7 by anonymous
edited Mar 7
Just do this

function javascript_decimal_test(number){
if(number< 0)
return "Negative"
return "Positive"
Welcome , qPocho is an online community for programmers share there knowledge.