Why is this condition still displaying when the variable was reassigned

image

I have been banging my head trying to understand why the if statement still runs. Any explanation would be helpful. Thanks!

You declared and initialized sale as true.

Then, you assigned false to sale.

Then, in your if condition, you again assigned true to sale.

The = operator is used for assignment. To make a comparison, use the == operator.

if (sale == true) { ...
2 Likes