Use the conditional operator in the checkEqual function to check if two numbers are equal or not. The function should return either "Equal" or "Not Equal"

Tell us what’s happening:
why this function not working? please help. thanks.

Your code so far


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

}

checkEqual(1, 2);

console.log()

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15.

Challenge: Use the Conditional (Ternary) Operator

Link to the challenge:

1 Like

The instructions for the challenge ask you to return either the string “Equal” or “Not Equal”.

You just gotta replace your true and false, with those strings respectively.

function checkEqual(a, b) {
   return a === b ? "Equal" : "Not Equal";
}

checkEqual(1, 2);