Problem with the "let code" in the video instruction
It seems like Andrew wrote a code:
is that a mistake because person.role = "Teacher" which is not a boolean result
If statements check to see if a condition is true. In this case (person.role) is the condition. The if statement does not return the contents of person.role which is a string. It checks to see if (person.role) is TRUTHY, meaning it is not set to: false, 0, an empty string or null and it is not undefined or NaN. Since it has a value of 'Teacher', the condition is then TRUTHY so the block of code in the if statement is executed.
The main thing is the if statement does not care what the actual value of person.role is. For example, you can set role 55544433234 and the block of code will still run. Try setting person.role to true and see what happens.
I hope this clears it up.
if(person.role) means if the person object has a role value. In this case, it is a string "Andrew". Therefore the if statement is true. Since it is true, it will perform the operation on the description variable.
Hope that helps.