What is the correct way for this code?


#1

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

This warning is being shown: Did you write an else if statement for if the moonPhase is mostly full?


var moonPhase = 'mostly full';

 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');
}


#3

You didn't include a part to check for if moonPhase === 'full'. Here is the code that the hint provides:

if (moonPhase === 'full') {

} else if (moonPhase === 'mostly full') {

} else if (moonPhase === 'mostly new') {

} else {

}

You just need to put the moonPhase vardeclaration at the top, and put theconsole.log() statements in place.


#4

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