-1

So , i'm currently learning control flow and i have to build a program with else if conditions. The problem is that i keep getting this errors for else ifs : "Expected an identifier and saw else" and "Expected an assigment or function call and instead saw an expression". Here's the code:

var moonPhase = 'full';

if (moonPhase === 'full') {
  console.log(Howwwlll!');}
      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(Caution, unknown ');}

//So what did i do wrong? Thanks in advance!

prasanth
  • 22,145
  • 4
  • 29
  • 53

1 Answers1

2

Remove the ; in the if and else condition. And also console.log() have a syntax error you are missing start ' single quotes

var moonPhase = 'full';

if (moonPhase === 'full') {
  console.log('Howwwlll!');
} 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('Caution, unknown');
}
prasanth
  • 22,145
  • 4
  • 29
  • 53