The examples conditions are not surrounded by quotes and are just instead their variable naming which obviously either evaluated to true or false. Is this because they are not needing to ‘calculate/evaluate’ anything before determining whether true or false and instead are just true or false by default.
I wrote this small program where I imagined a log in system. In this example, I wrapped my conditions in brackets because the value is not known until the code runs within the brackets. Here is my code:
let password = 'test123'; let loginStatus = (prompt('What is your password?') === password) ? true : false; let status = loginStatus; let alert = (status) ? 'You are now logged in!' : 'Incorrect Password!'; console.log(alert);
Hope this question makes some sense but in summary, when do I need brackets around the condition and when do I not need brackets.