When are parenthesis needed in return statement

Tell us what’s happening:
So I checked and all that is different in the answer is adding parenthesis around the return statement. I understand that that is needed if it is multiple lines but if there is only one line of code the parenthesis are not necessary correct?

Your code so far
function checkEqual(a, b) {
return a = b ? “true” : “false”;
}

checkEqual(1, 2);


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

checkEqual(1, 2);

Your browser information:

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

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

whoops figured it out it’s the parenthesis around true and false that were giving me the error

In your comparison you are not using the comparison operator. You are actually setting a equal to b. I think that they were expecting you to return a Boolean true or false. You are returning strings

Usually they’re just there to make the statement more readable, but sometimes they are also needed to control order of operations, just as they are in other cases.

1 Like

Thanks yea didn’t realize i’d only put one equal sign as well. Thanks for the clarification on the parenthesis as well.