For all others who might have questions to the third example. Let’s start from unchanged expression, which looks like this:
let favoritePhrase = ‘Love That!’;
if (favoritePhrase === ‘Love That!’) {
console.log(‘I love that!’);
} else {
console.log(“I don’t love that!”);
}
Now we are asked to change it using ternary operator. To make it properly we need to read very carefully what our condition says:
(favoritePhrase === ‘Love That!’)
That is why to change it properly we need to KEEP condition unchanged. Otherwise, we are answering a different question. Our question is: is this strictly the same type and value (by definition of ===), so using full statement:_____ favoritePhrase === ‘Love That!’ ____ is must have this time if you will. Therefore the proper change will look that way:
favoritePhrase === ‘Love That!’ ? console.log(‘I love that!’) : console.log(“I don’t love that!”);
I hope that is clear and easy now. Please let me know if it helps?