Ternary operator


#1

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
ternary operator

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
doesn’t execute

```

let isLocked = false;

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

let isCorrect = true;

if (isCorrect) {
console.log(‘Correct!’);
} else {
console.log(‘Incorrect!’);
}

let favoritePhrase = ‘Love That!’;

if (favoritePhrase === ‘Love That!’) {
console.log(‘I love that!’);
} else {
console.log(“I don’t love that!”);
}

<do not remove the three backticks above>

#2

You need to write the ternary operator for the code to run correctly, i don’t see it?


#3

Hey @carman101 can I ask why there is a question mark inside the first conditional of your if statement?

if (isLocked?) {

The right advice or code review, isnt always so easy or quick, for future reference share the lesson name, the webpage link, the step you are struggling on, also the code you tried and sometimes the error message that pops up. :thinking:

All of this information is really helpful for you to mull over and it introduces us to the problem so we can point you in the right direction in a timely manner :handshake: :tada:


#4

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