Why the exercise returns ‘I love that!’

Hi there!

So I understand why the syntax is how it is, the only thing I’m struggling to understand is why the exercise returns ‘I love that!’ even though the favouritePhrase value is not the same as the printed result, and it uses the strict equal operator.

Is it because both types are strings so it becomes “truthy”? is that what is meant by the string literals having no relations in logged values?

In case this post gets split, let’s be sure to have a link to the lesson. Please post a link to the exercise. We can wrestle this question from there.

absoulety, the Ternary Operators exercise

Exercise in question

A conditional is based upon a given state meeting a particular requirement. The output of that will not necessarily be the value used in the condition but could be any value. The conditional is behind us at that point since we’ve made our journey past it. Now we’re into the action.

alright, interesting, I guess I’m not understanding what exactly the requirement is in this case.

Because if I play around with the code and remove the exclamation point like so:
favoritePhrase === ‘Love That’ – running the program returns “I don’t love that!”

In my mind, both of these conditions, even the one to pass the exercise are false and should return “I don’t love that”, what point am I missing?

The way you’ve worded your question seems to indicate you’re a little confused about what is being checked.
The condition being checked is that favoritePhrase is the same as “Love That!” - which is what favoritePhrase is set to.
The bit that is being printed out is just displaying which bit of code is being processed. You could change the console.log values to something else if it helps.

Hope that helps.

lolol ■■■■, that’s it! that’s what I’ve been overlooking…

Makes complete sense now, I was looking too deep into it, everything was surface level.

Thank you,

1 Like