Can someone explain why my code isn't working

this is from the Use Multiple Conditional (Ternary) Operators challenge;

function checkSign(num) {
  return (num === (num)) ? "positive"
  : (num === (-(num))) ? "negative"
  :  "zero";



this is always true, a number is always equal to itself

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

ok thanks for the correction.
Also aside from

num  < 0 ? "negative" 

Which other way can one check a number is negative or not?

why do you need a different way?

but you could use Math.abs to do what you were trying to do there

you could raise a number to the power of that number, with Math.pow, if the result is less than one the number you need to check is negative

1 Like

was curious :sweat_smile:
thanks tho