Problem with Use the Conditional (Ternary) Operator

Code is not working on this JavaScript Project

return a == b ? true : false;

I tried many variations

return a === b ? true : false;
return a === b ? false: false;
return a > b ? true: false; … etc

Nothing is working!

Provide more context, where are using it?

Basic JavaScript: Use the Conditional (Ternary) Operator

function checkEqual(a, b) {

return a == b ? true : false;


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

I just copy pasted your code and it worked fcctern

I wonder why my editor keep rejecting it? I’m using Mozilla firefox maybe that’s the issue?

I keep getting
// running tests

checkEqual(1, 2)

should return “Not Equal”

checkEqual(1, 1)

should return “Equal”

checkEqual(1, -1)

should return “Not Equal” // tests completed

I’m using firefox too

Yes now, you’re not returning the right values
try return a == b ? "Equal" : "Not Equal"

Thanks Bro! I actually tried that but I left out the Quotes!

No problem, but I think the quotes should be there because this is a string.

1 Like

True! Now I can finish this JavaScript section! onWard to victory! :smiley:

1 Like

Keep it moving @ArronPro1