Ternary Operator

There is an error when I run this but I don’t see a mistake:

let isLocked = false;

isLocked ? console.log(‘You will need a key to open the door.’) : console.log(‘You will not need a key to open the door.’);

let isCorrect = true;

isCorrect ? console.log(‘Correct!’) : console.log(‘Incorrect!’);

let favoritePhrase = ‘Love That!’;

favoritePhrase === ‘Love That!’ ? console.log(‘I love that!’) : console.log(“I don’t love that!”);

Could we have a link to the exercise please? Thank you.

Ternary operator

1 Like

I copy/pasted your code, and the only thing that I changed were the quotes ' ' (all of them).
That solved it.

You’ll want to make sure that all strings in your editor appear yellow, not orange (yellow means the strings are recognized as strings, and that it works).

Ok, I change it all and now it works, thanks!!
until now I realized about the colors…
Again, thank you very much.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.