If/Else


#1

I’m doing the exercise and I go cool everything works, but I keep getting an error saying did I include the else statement for invalid moon phase. I know my code is correct because its executing the else statement when i put in another moon phase. Is this exercise bugged? Here’s my code.

let moonPhase = ‘waning’;

if(moonPhase === ‘full’)
{
console.log(‘Howl!’);
}

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

else and { should be on a single line for validation purposes.


#3

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