Basic JavaScript: Use the Conditional (Ternary) Operator Can't pass the test

Tell us what’s happening:

Basic JavaScript: Use the Conditional (Ternary) Operator

Your code so far

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

checkEqual(1, 2);

The result I got from this exercise is:

// running tests
checkEqual(1, 2) should return false
checkEqual(1, -1) should return false
// tests completed

Please help! I can’t find the answer to it.
Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0.

Link to the challenge:

1 Like

Remember, a = b is an assignment (assigning the value stored in b into the variable a), while a == b is a comparison. Which are you doing?

Oh! Thanks for reminding me the double equal when I’m doing comparison. I got it pass now!

1 Like