JavaScript(JS) JS check if a number is positive, negative, or zero

http‮w//:s‬ww.theitroad.com

To check whether a number is positive, negative, or zero in JavaScript, you can use a simple if...else statement.

Here's an example:

let num = 5;

if (num > 0) {
  console.log("The number is positive");
} else if (num < 0) {
  console.log("The number is negative");
} else {
  console.log("The number is zero");
}

In this example, we have assigned the value 5 to the variable num. We then check whether num is greater than 0 using an if statement. If it is, we print the message "The number is positive". If num is less than 0, we print the message "The number is negative". Otherwise, we print the message "The number is zero".

You can replace the value of num with any number you want to check.