Control Flow: Werefolf (else if) exercise not accepting nested ternary operators


The lesson won’t let me past step 1, even though the code does what was asked.

Lesson in question:

There are no proper error messages. My code behaves as it is supposed to.
The lesson, however, says i failed, and gives me this message: “Did you write an else if statement for if the moonPhase is mostly new?”

Here is my code:

var moonPhase = 'full';

  moonPhase === 'full' ? console.log('Howwwwlll!!')
: moonPhase === 'mostly full' ? console.log('Arms and legs are getting hairier')
: moonPhase === 'mostly new' ? console.log('Back on two feet')
: console.log('Invalid moon phase');


We are asked to follow the instructions given. That means using: if, else if and an else statement. Do you know how to do this? Example:

if (that === that) {
//we can use console.log(); here.


These ternary operators act as if/else/else if statements. When I tried using them in earlier exercises, they let it pass.


I know, but they want us to do it the way they Codecademy wants to. (with the statements and such)


Ok. I still find it strange that they would let me use them in the other exercises where we were asked to use if/else, but not this one.


Yeah, its odd. :confused: But if you have experience with this language, then doing this should be a breeze. :slight_smile:


Yeah. Just submitted using normal if/else if/else.


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