Search snippets
Browse Code Answers
FAQ
Usage docs
Log In
Sign Up
Home
Javascript
Use multiple conditional operators in the checkSign function to check if a number is positive, negative or zero. The function should return "positive", "negative" or "zero".
thedogsfoot
Programming language:
Javascript
2021-05-22 21:03:24
0
Q:
Use multiple conditional operators in the checkSign function to check if a number is positive, negative or zero. The function should return "positive", "negative" or "zero".
Aryan Ali
Code:
Javascript
2021-05-20 15:14:55
function checkSign(num) { return (num > 0) ? 'positive' : (num < 0) ? 'negative' : 'zero'; }
0
Tags
number
use
multiple
function
check
con
turn
sign
return
Related
check if number is negative javascript
Use the conditional operator in the checkEqual function to check if two numbers are equal or not. The function should return either "Equal" or "Not Equal".
New to Communities?
Join the community