Ternary operator

Hi. I’m stuck on Use the Conditional (Ternary) Operator.

My syntax:

function checkEqual(a, b) 
  return a > b ? true : false;

checkEqual(1, 2);

Thanks in advance for any help.

Ternary opeators go like this :

return "if condition is true" ? (condition goes here) : else part; 

See if this helps.

1 Like

It seems I misunderstood the instructions. I read them again and amended my code accordingly. Thanks for your help. Sorry for the inconvenience.

Just to make it clear for anyone else reading this later. The problem was not with the syntax of the ternary operator but that the check in the assignment is for equality (===), not greater than (>).

1 Like