Truthy falsesy

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!’) :

let favorite_Phrase = ‘Love That!’;

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

whats wrong in the th3 block

Welcome to the Get Help category!

This is where you can ask questions about your code. Some important things to remember when posting in this category :slight_smile:

  • Learn how to ask a good question and get a good answer!
  • Remember to include a link to the exercise you need help with!
  • If someone answers your question, please mark their response as a solution :white_check_mark:
  • Once you understand a new concept, come back and try to help someone else!

i cleared it from solution removed the _ in phase

but still not sure why we define the

let favoritePhrase = 'Love That! ’

then next line we need the === seems like we assign the value twice

and why sosnt the strings need () in truthy falsy

The = assigns the value.
The === checks whether things are equal (true if equal, false if not equal)

non-empty strings are truthy

if ("a string") {
  console.log("do stuff");

is like doing

if (true) {
  console.log("do stuff");
1 Like

Until coercion is written out of the language we must maintain a distinction between equality and identity. For practical purposes equality might mean, have the same appearance. A numeral in any form still looks like a number. Identity is an exact match both in type and in value.

Yeah, I know this is nitpicking, but with good intentions.

==   =>  equality  "1" == 1   // true

===  =>  identity  "1" === 1  // false