Ternary operator

Ternary operator
0

#1

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.


#2

Ternary opeators go like this :

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

See if this helps.


#3

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


#4

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 (>).