Control flow if/else statement


Hi y’all can some one review this from here and explain me what is wrong

let moonPhase = 'full';
let isFoggyNight = false;

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');
} if (moonPhase === 'full' && isFoggyNight) {
  console.log(moonPhase && isFoggyNight);

Output is


It should be

'Invalid moon phase'


did you look at the code you posted? By the color you can tell something is wrong, and forgot to close a string somewhere


i’ve corrected the an error when i add isFoggyNight



else if (moonPhase === '' ) {
  console.log('Invalid moon phase');

should be else, given all other cases are invalid moon phases

this else clause should have been removed:

else { console.log('I swear I am not a werewolf.');

actually, you should have changed it, but given you add a new one, you need to remove this one

you need to check if the moon is full and its a foggy night (using and operator)

if further assistance is required, post an updated version of your code and the exercise url


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