Else if statements

why the error?

var moonPhase = ‘full’;

if (moonPhase === ‘full’) {
} else if (moonPhase === ‘mostly full’) {
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’);

I put double quotes. I used a site called repl.it for practicing programming. You can look up node.js. Its really good to get fast feedback

Hi @blogjumper55099,

As your code still works because the condition is checking whether moonPhase is 'full', and it is, so it printed 'Howl'. Thus, you’re wondering why the error? But the lesson is throwing error because it is checking your full code, and there is one error there.

Just a Hint for you to debug your code:

You have only one mistake in your full code, but that one mistake means a lot in coding, try check from this perspective, include every spellings and case-wise. I can just tell you where it is, but it is better if you can find it yourself. Then you will sharpen your skill of debugging. It’s another skill you will depend a lot while learning to code.

Side Note:

  • If you have any question in future, it is best to post a link towards the lesson, state what error it throws and use proper markdown to format your code in your post (use the </> icon to wrap your code), refer more here

With that, I hope you can find that one error, come back again if you really hit the road block.

Happy coding! :slight_smile:

1 Like

I don’t know.

Maybe try adding a semicolon at the end.
Also, if you do not get the console.log wording exactly correct, sometimes they will nag you about it. Hope I help.

@ionatan , could you possibly help? You’re very good at this.

D: flattery can get you things, but there’s nothing here I can answer (which error? which exercise? what does the code really look like?)

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