Control Flow Help


#1


https://www.codecademy.com/courses/learn-javascript/lessons/control-flow/exercises/else-if?action=lesson_resume


Did 'Arms and legs are getting hairier' log to the console?


var moonPhase = 'mostly full';

if (moonPhase === 'full') {
  console.log('Howwwlll!!');
} else {
  console.log('I swear I am not a werewolf...');
} 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')


#2

if (moonPhase === 'full') {
  console.log('Howwwlll!!');
} else {
  console.log('I swear I am not a werewolf...');

Because you cannot have any else if after an else.

Your else will have to become an else if with a condition between brackets.

Mind the last else as well. Open and close that console.log with curly brackets.


if (condition) {
  // do stuff
} else if (another condition) {
  // do something else
} else {
  // yet something else
}

#3

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