Comparisons Operators II


I am stuck in the if/else portion. Not sure if I am typing this correctly?
var moonPhase = ‘full’;
if (moonPhase = ‘full’); {
console.log(‘Howwwwlll!!’); }
else if (moonPhase);
console.log(‘I swear I am not a werewolf…’)

<do not remove the three backticks above>


@zaynberger from a quick glance I can see that you are missing some syntax

 if (condition1) {
    block of code to be executed if condition1 is true
} else {
    block of code to be executed if the condition1 is false

Also the right advice or code review, isnt always this easy or quick, for future reference, share the lesson name, the webpage link, the step you are struggling on, also the code you tried and sometimes the error message that pops up. :thinking:

All of this information is really helpful for you to mull over and it introduces us to the problem so we can point you in the right direction in a timely manner :handshake: :tada:


There is a difference between using =, ==, and ===. The first one is for asignment, the other two for comparisons, AND you need to open and close {…}.


@zaynberger Hi, You should to re-read Control Flow, lesson 4. Comparisons Operators II. You put only one equal sign in your if statement, and since you’re comparing whether or not moonPhase is equal to full, you want to use === instead of =. Your var statement is correct because you are only assigning a value to moonPhase.

You want to take out the semicolons on the if and else if lines:
if (moonPhase = ‘full’); {
else if (moonPhase);

with if and else if statements you put them at the end of the statement, right before the closing curly brace;
console.log(‘Howwwwlll!!’); } is correct
and you need to put a semicolon at the end of;
console.log(‘I swear I am not a werewolf…’)

Also, you want to put an open curly brace at the end of your else if line .
else if(moonPhase).


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.