Why do we write `if(sale)` instead of `if(sale===true)`?

Yes, for sure. This is not funny to waste time typing questions if you found the answer on the forum.


I have exactly the same code and it works. That’s mean that the message “Time to wait for a sale” appears in my terminal. So the code seems to be not the problem.

let sale = true;
sale = false;
if(sale) {
console.log(‘Time to buy!’);
else {
console.log(‘Time to wait for a sale.’)

Hello everyone. First timer here. I’d like to get some clarification: is ‘sale === true’ the same as ‘sale = true’?
In other words, can the assignment operator ‘=’ be written as ‘===’?

Not at all. The single = is the assignment operator, === is the identity operator (identical relation in type and value).

Thank you for responding.

1 Like