CONTROL FLOW else if Statements 7/11


#1

My code is not working. Can someone please let me know where I am going wrong?

let moonPhase = ’ mostly full’;

if (moonPhase === ‘mostly full’) {
console.log(‘Howl!’);
} else if {
console.log(‘Arms and legs are getting hairier.’);
} else if (moonPhase === ‘mostly new’) {
console.log(‘Back on two feet’);
} else {
console.log(‘Invalid moon phase’);
}

These are the instructions:

We all know that turning into a werewolf is not an instantaneous event. It happens in stages. So let’s expand our program to accommodate that.

If the moon is mostly full, log Arms and legs are getting hairier. If the moon is mostly new, log Back on two feet.

If someone enters in an invalid moon phase, make sure to log Invalid moon phase in the else code block.

Set moonPhase to mostly full and run your code.

We expect Arms and legs are getting hairier to log to the console.

Set moonPhase to mostly new and run your code.

We expect Back on two feet to log to the console.

Now set moonPhase to solar eclipse and run your code.

Since there is not an else if condition for solar eclipse, we expect the default else code block to run. You should see Invalid moon phase print to the console.


#2

else if requires a conditional expression.

else if (condition)