Use the Conditional (Ternary) Operator not bringing correct result

Tell us what’s happening:

Your code so far

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

checkEqual(1, 2);

When I input the above everything else works except it brings a>b as true

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36.

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

You’re being asked to check if the two inputs are equal, not whether the first is greater than the second: that is the example, your code will not be the same.

Thanks for your input.
I changed to this
function checkEqual(a, b) {
return a=b ? false: true;
}

checkEqual(1, 2);

now its bringing checkEqual(1, 1) should return true

Thanks to your input I finally solved it.

1 Like

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

markdown_Forums

How did you solve ? What was the code ? i didn’t get it

This is the code I used

3 Likes

Oooh … Thanks … It was giving me a really hard time .

1 Like