Basic javascript Use the Conditional (Ternary) Operator

any help with this guys?m im stuck

function checkEqual(a, b) {

return a === b ? true ! false

}

checkEqual(1, 2);

ternary operator use this ( : ) not(!)

1 Like

Hey @ser1!

It might help others if you include the lesson link in your post.

still doesnt pass here is the code

function checkEqual(a, b) {

retuurn a === b ? true : false;

}

checkEqual(1, 2);

FCC instructions:
The function should return either “Equal” or “Not Equal”.

you have spelling error

That’s true to. Good catch @hafsaR . :grinning:

But it still won’t pass because it is return the wrong things

1 Like
function checkEqual(a, b) {

return a === b ? true : false;

}

checkEqual(1, 2)

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

What happens when you try this?

only one test is passing

what’s code now? what’s the challenge link?

1 Like

Basic JavaScript: Use the Conditional (Ternary) Operator

the challenge link is the url that is in the browser url bar when you have the challenge open

here is the code

function checkEqual(a, b) {

return a === b ? true : false;

}

checkEqual(1, 2);

and what appear in the console when you run the tests?

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

look at your code, could it return "Equal" or "Not Equal"?


Still doesn’t pass