Question
I changed moonPhase
to something else but the code still prints out “Howl!”. What’s wrong?
Answer
Make sure you’re using ===
to compare moonPhase
to ‘full’. It is a common mistake to use =
instead of ===
. =
is used for assignment (setting a variable equal to a value), not checking if two things are equal. What you’re actually doing when you use =
is setting moonPhase
to ‘full’ and then the if statement converts the result of moonPhase
into a boolean and checks if it is truthy.