Use the Conditional (Ternary) Operator_20181228

Tell us what’s happening:
The result is correct by codes what i input but it doesn’t let me pass the test, what should i change?

Your code so far


function checkEqual(a, b) {
 return a==b ? "true" : "false";
}

console.log(checkEqual(1, -1));

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/use-the-conditional-ternary-operator

You are returning strings “true” and “false” what you are required to return is the boolean object true or false

remove the quotes and you should be good.

2 Likes
function checkEqual(a, b) {
  return a ==b? true : false;
}

checkEqual(1, 2);

It worked for me correctly.
You need to return the boolean type. Not as string type.

1 Like

Thanks! it was boolean type,

1 Like