Use the Conditional (Ternary) Operator- don't know what i'm doing wrong

Tell us what’s happening:

Your code so far


function checkEqual(a, b) {
  return a = b ? "True" : "False";
}


checkEqual(1, 2);

Your browser information:

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

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

So there’s a world of difference between

a = b

and

a == b

in javascript. The first assigns the value of b to the variable a, while the second compares the value in a to the value in b. Which are you using?

You should also return the values true and false, and not strings.

1 Like

how do i return the values as not strings? conditional operator wants me to input true and false between quotes…

a == b makes more sense yet i’m still having trouble returning true or false as not strings

to return a boolean (true or false) just remove the “” and make small caps

e.g

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


checkEqual(1, 2);

They are primitive boolean types having the values true or false.

You can check for the values and have them returned.

false === false;
// true

true === false;
// false

@ramilsaavedra

Again, don’t use the assignment operator (=) but the equality operator (== or strict ===).

1 Like

thank you! that makes more sense

1 Like

Hi @amypolito :grinning:

Try -

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

checkEqual(1, 2);